title: MySQLdb: Pandas data-frame to SQL database error: not all arguments converted during string formatting
body: <p>So, I wanted to move a dataframe to a database into a table but I am encountering a few problems. I made the dataframe using the pandas library and wanted to upload the data into a table in my database. </p>
  
  <p>Relevant snippets of my Code and the error details are as follows:</p>
  
  <pre><code>#CONNECTION TO SQL DATABASE
  db=sql.connect(host="localhost",user="root",passwd="password",db="database_name")
  cur=db.cursor()
  #CONVERTING DATAFRAME(df_final) INTO TABLE
  df_final.to_sql(con=db, name='finaltable', if_exists='replace', chunksize=5000)
  </code></pre>
  
  <p>Error details:</p>
  
  <pre><code>Traceback (most recent call last):
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\M
  ySQLdb\cursors.py", line 238, in execute
  query = query % args
  TypeError: not all arguments converted during string formatting
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\io\sql.py", line 1400, in execute
  cur.execute(*args)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\M
  ySQLdb\cursors.py", line 240, in execute
  self.errorhandler(self, ProgrammingError, str(m))
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\M
  ySQLdb\connections.py", line 52, in defaulterrorhandler
  raise errorclass(errorvalue)
  _mysql_exceptions.ProgrammingError: not all arguments converted during string fo
  rmatting
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
  File "pt.py", line 77, in &lt;module&gt;
  df_final.to_sql(con=db, name='finaltable', if_exists='replace', chunksize=50
  00)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\core\generic.py", line 2127, in to_sql
  dtype=dtype)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\io\sql.py", line 450, in to_sql
  chunksize=chunksize, dtype=dtype)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\io\sql.py", line 1502, in to_sql
  table.create()
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\io\sql.py", line 561, in create
  if self.exists():
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\io\sql.py", line 549, in exists
  return self.pd_sql.has_table(self.name, self.schema)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\io\sql.py", line 1514, in has_table
  return len(self.execute(query, [name, ]).fetchall()) &gt; 0
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\io\sql.py", line 1412, in execute
  raise_with_traceback(ex)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\compat\__init__.py", line 403, in raise_with_traceback
  raise exc.with_traceback(traceback)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\p
  andas\io\sql.py", line 1400, in execute
  cur.execute(*args)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\M
  ySQLdb\cursors.py", line 240, in execute
  self.errorhandler(self, ProgrammingError, str(m))
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\M
  ySQLdb\connections.py", line 52, in defaulterrorhandler
  raise errorclass(errorvalue)
  pandas.io.sql.DatabaseError: Execution failed on sql 'SELECT name FROM 
  sqlite_ma
  ster WHERE type='table' AND name=?;': not all arguments converted during string
  formatting
  </code></pre>