I am trying to create and load a table in Snowflake using Python. The data is in a pandas data frame. Below is the code I'm using. The table gets created, but it has 0 rows and there's no error message shown.
with engine.connect() as con:
data.head(0).to_sql(name=table_name, con=con, if_exists="replace", index=False)
query="put file://" + file_path + "* @%" + table_name
con.execute(text(query))
query2="copy into " + table_name + " ON_ERROR=CONTINUE"
con.execute(text(query2))
Some notes:
Moving the answer from comment to answer for closure:
You need to commit:
conn.commit()
or use withengine.begin() as conn:
to commit automatically.
(@snakecharmerb I can delete this answer if you want to provide one owned by you)