The object df is of type pandas.core.frame.DataFrame.
In [1]: type(df)
Out[1]: pandas.core.frame.DataFrame
The index of df is a DatetimeIndex
In [2]: type(df.index)
Out[2]: pandas.tseries.index.DatetimeIndex
And con gives a working MySQLdb connection
In [3]: type(con)
Out[3]: MySQLdb.connections.Connection
I've not been able to get this dataframe entered into a MySQL database correctly, specifically, the date field comes through as null when using the following (as well as some variations on this).
df.to_sql( name='existing_table',con=con, if_exists='append', index=True, index_label='date', flavor='mysql', dtype={'date': datetime.date})
What are the steps required to have this dataframe entered correctly into a local MySQL database, with 'date' as a date field in the db?
dtype={'date': datetime.date}you usedtype={'date': datetime.datetime}? If not, does it simply insertnullto the db or does it throw an error? Also, by readingto_sqldocumentation here: pandas.pydata.org/pandas-docs/stable/generated/… , it seems likedtypeis optional, but if present I believe it should contain all the columns.