title: Writing to MySQL database with pandas using SQLAlchemy, to_sql
body: <p>trying to write pandas dataframe to MySQL table using <code>to_sql</code>.  Previously been using <code>flavor='mysql'</code>, however it will be depreciated in the future and wanted to start the transition to using SQLAlchemy engine.</p>
  
  <p>sample code:</p>
  
  <pre><code>import pandas as pd
  import mysql.connector
  from sqlalchemy import create_engine
  
  engine = create_engine('mysql+mysqlconnector://[user]:[pass]@[host]:[port]/[schema]', echo=False)
  cnx = engine.raw_connection()
  data = pd.read_sql('SELECT * FROM sample_table', cnx)
  data.to_sql(name='sample_table2', con=cnx, if_exists = 'append', index=False)
  </code></pre>
  
  <p>The read works fine but the <code>to_sql</code> has an error:</p>
  
  <blockquote>
    <p>DatabaseError: Execution failed on sql 'SELECT name FROM sqlite_master
    WHERE type='table' AND name=?;': Wrong number of arguments during
    string formatting</p>
  </blockquote>
  
  <p>Why does it look like it is trying to use sqlite? What is the correct use of a sqlalchemy connection with mysql and specifically mysql.connector?</p>
  
  <p>I also tried passing the engine in as the connection as well, and that gave me an error referencing no cursor object.</p>
  
  <pre><code>data.to_sql(name='sample_table2', con=engine, if_exists = 'append', index=False)
  &gt;&gt;AttributeError: 'Engine' object has no attribute 'cursor'
  </code></pre>