python - Pandas to_sql not working with SQL Alchemy ...
stackoverflow.com › questions › 54953936Mar 02, 2019 · Pandas to_sql not working with SQL Alchemy connection. Bookmark this question. Show activity on this post. I'm connecting to a MySQL database with SQL alchemy using the following code. from sqlalchemy import create_engine import pandas as pd query = "SELECT * FROM hello" engine = create_engine ("mysql+pymysql://root:new_pass@localhost:3306/toronto_analytics") engine = engine.raw_connection () df = pd.DataFrame ( {"bob":"hello", "joe":14}, index= [0]) df.to_sql ('new_table', engine)
pandas.DataFrame.to_sql — pandas 1.3.5 documentation
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_sql.htmlpandas.DataFrame.to_sql¶ DataFrame. to_sql (name, con, schema = None, if_exists = 'fail', index = True, index_label = None, chunksize = None, dtype = None, method = None) [source] ¶ Write records stored in a DataFrame to a SQL database. Databases supported by SQLAlchemy are supported. Tables can be newly created, appended to, or overwritten.