User bio
404 bio not found
Member since Apr 5, 2019
Pinned posts:
Replies:

Hi,

If i remember correctly, the default behavior of the to_sql method is to use a transaction to insert the data.

What i do is using with statement to ensure that the transaction is commited and closed after the insert:

with engine.connect() as conn:
    train_df.to_sql(name='table1', con=conn, if_exists='replace', index=False)

Otherwise, you can commit the transaction manually:

conn = engine.connect()
train_df.to_sql(name='table1', con=conn, if_exists='replace', index=False)
conn.commit()
conn.close()

That's what i do, hope it helps.

Open Exchange applications:
Certifications & Credly badges:
Global Masters badges:
Followers:
Following:
Guillaume has not followed anybody yet.