I am trying to insert columns of data that I extracted from .csv file into MySQL using Pandas (Python).
Here is my code that I have so far.
import pandas as pd
from pandas.io import sql
from sqlalchemy import create_engine
engine = create_engine('mysql://username:password@localhost/dbname')
with engine.connect() as conn, conn.begin():
df = pd.read_csv('File.csv', usercols=['ID', 'START_DATE'], skiprows=skip)
print(df)
df.to_sql(con=con, name='Table1', if_exists='replace', flavor='mysql')
But, it does not mention about specific column names in Table1..
How do we express that?
DataFrame.to_sql... examples are in the docs. pandas.pydata.org/pandas-docs/stable/io.html#io-sql