I need help to get this working. I have a pd.DataFrame (df)
, which I need to load to a MySQL database. I don\'t understand what the error message means and how
When using sqlalchemy, you should pass the engine and not the raw connection:
engine = create_engine("mysql+mysqldb://...")
df.to_sql('demand_forecast_t', engine, if_exists='replace', index=False)
Writing to MySQL without sqlalchemy (so with specifying flavor='mysql'
) is deprecated.
When the problem is that you have a too large frame to write at once, you can use the chunksize
keyword (see the docstring). Eg:
df.to_sql('demand_forecast_t', engine, if_exists='replace', chunksize=10000)