title: Getting error from copying row from table to another table
body: <p>I am writing a piece of python code to copy one table from one mysql db to to another mysql db.</p>
  
  <p>I came across some problems like first it was reading null, empty values as 'None' which I had to convert to 'NULL'.</p>
  
  <p>Now it showing following error -</p>
  
  <pre><code>pymysql.err.InternalError: (1630, u"FUNCTION datetime.datetime does not exist. 
  Check the 'Function Name Parsing and Resolution' section in the Reference Manual")
  </code></pre>
  
  <p>When I print the row I can see the entry of datetime.datetime(2014, 8, 25, 8, 24, 51). 
  I tried solve this problem by replacing datetime.datetime by datetime.time (<a href="http://pymotw.com/2/datetime/" rel="nofollow">http://pymotw.com/2/datetime/</a>) But that also failed.</p>
  
  <p>My code is as follows :</p>
  
  <pre><code>import re
  from db import conn_main ### database from where to copy
  from db import conn ### database where to copy
  import datetime
  
  curr1 = conn_main.cursor()
  curr2 = conn.cursor()
  
  query = 'SELECT * FROM mytable limit 10'
  curr1.execute(query)
  for row in curr1:
      if row[0] is None or not row[0]:
              print "error: empty row",row[0]
              continue
      else:
              print "ROW - %s\n" % str(row)
              row = re.sub('None','NULL',str(row))
              query = 'replace into mytable values ' + str(row)
              curr2.execute(query)
  
  curr2.commit()
  curr1.close()
  curr2.close()
  </code></pre>
  
  <p>Traceback &amp; output row: </p>
  
  <pre><code>ROW - (1, '501733938','xyz.emails@gmail.com', None, 'https://www.facebook.com/xyz',
   None, None, None, None, None, '2014-08-10T06:06:33+0000', None, 'xyz', None,
   datetime.datetime(2014, 8, 25, 8, 24, 51), None, None, None, None, None, None, None, 
   None, None, None, None, None, None, None, None, None)
  
  Traceback (most recent call last):
    File "MY_PYTHON_CODE_FILE_PATH", line 390, in &lt;module&gt; curr2.execute(query)
    File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 132, in execute result = self._query(query)
    File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 271, in _query conn.query(q)
    File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 726, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered)
    File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 861, in _read_query_result result.read()
    File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1064, in read first_packet = self.connection._read_packet()
    File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 826, in _read_packet packet.check_error()
    File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 370, in check_error raise_mysql_exception(self._data)
    File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 116, in raise_mysql_exception _check_mysql_exception(errinfo)
    File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 112, in _check_mysql_exception raise InternalError(errno, errorvalue)
  </code></pre>
  
  <p>Can someone help remove this error ... or suggest any other better way to copy table from one database to another in python.</p>