title: 'numpy.float64' object has no attribute 'translate' Inserting value to Mysql in Python
body: <pre><code>import dataset
  db = dataset.connect(....)
  table = db[...]
  </code></pre>
  
  <p>When I try to insert some value into Mysql table, this error occurred. </p>
  
  <p>Sample Value I am inserting to the table:</p>
  
  <pre><code>print("Buy", ticker, price, date, OType, OSize)
  Buy AAPL 93.4357142857 2016-05-12 Market 200
  data = dict(Order_Side='Buy',Ticker=ticker, Price=price, 
                              Order_Date= date, Order_Type = OType, Volume = OSize )
  table.insert(data)
  </code></pre>
  
  <p>error message:</p>
  
  <pre><code>Traceback (most recent call last):
  
    File "&lt;ipython-input-3-b7ab0c98f72f&gt;", line 1, in &lt;module&gt;
      runfile('C:/Users/SwigelUser/Documents/GitHub/Trading/Strategies/strat_MA_ExecTest.py', wdir='C:/Users/SwigelUser/Documents/GitHub/Trading/Strategies')
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
      execfile(filename, namespace)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
      exec(compile(f.read(), filename, 'exec'), namespace)
  
    File "C:/Users/SwigelUser/Documents/GitHub/Trading/Strategies/strat_MA_ExecTest.py", line 69, in &lt;module&gt;
      MA_Stra(start_length=7,end_length=10,start_date=date(2016,5,12),end_date=date(2016,6,18))
  
    File "C:/Users/SwigelUser/Documents/GitHub/Trading/Strategies/strat_MA_ExecTest.py", line 66, in MA_Stra
      table.insert(data1)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\dataset\persistence\table.py", line 87, in insert
      res = self.database.executable.execute(self.table.insert(row))
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 945, in execute
      return meth(self, multiparams, params)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\sqlalchemy\sql\elements.py", line 263, in _execute_on_connection
      return connection._execute_clauseelement(self, multiparams, params)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1053, in _execute_clauseelement
      compiled_sql, distilled_params
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1189, in _execute_context
      context)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1405, in _handle_dbapi_exception
      util.reraise(*exc_info)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\sqlalchemy\util\compat.py", line 187, in reraise
      raise value
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1182, in _execute_context
      context)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\sqlalchemy\engine\default.py", line 470, in do_execute
      cursor.execute(statement, parameters)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\pymysql\cursors.py", line 164, in execute
      query = self.mogrify(query, args)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\pymysql\cursors.py", line 143, in mogrify
      query = query % self._escape_args(args, conn)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\pymysql\cursors.py", line 123, in _escape_args
      return dict((key, conn.literal(val)) for (key, val) in args.items())
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\pymysql\cursors.py", line 123, in &lt;genexpr&gt;
      return dict((key, conn.literal(val)) for (key, val) in args.items())
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\pymysql\connections.py", line 821, in literal
      return self.escape(obj, self.encoders)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\pymysql\connections.py", line 814, in escape
      return escape_item(obj, self.charset, mapping=mapping)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\pymysql\converters.py", line 27, in escape_item
      val = encoder(val, mapping)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\pymysql\converters.py", line 110, in escape_unicode
      return u"'%s'" % _escape_unicode(value)
  
    File "C:\Users\SwigelUser\Anaconda3\lib\site-packages\pymysql\converters.py", line 73, in _escape_unicode
      return value.translate(_escape_table)
  
  AttributeError: 'numpy.float64' object has no attribute 'translate'
  </code></pre>
  
  <p>What have caused this error? How could I solve this.
  It seems like I entered too much code here,thus I will have to type lots of none sense in order to submit.</p>
  
  <p>my price and date variable comes from a dataframe:</p>
  
  <pre><code>for i in range(len(All_Tickers)-1-len(Current_Date),len(All_Tickers)-1):
      price = All_Tickers[str(length) + 'day_MA'][i]
      date = All_Tickers['Date'][i+1]
  </code></pre>
  
  <p>According to the answer below, the problem should be the type of price is np.float64, how can I convert this variable to type float?</p>