Bug with function df.to_sql(if_exists = 'replace')

80 views Asked by At

I'm updating a table from a dataframe that has no more than 40 rows and 8 columns (little data, user information, nothing heavy) with the following code

df.to_sql(table_name,self.engine,if_exists = 'replace',index=False)

Lately this method hasn't been working for me; for some reason it gets stuck in this process and never finishes (or finishes hours later), so I have to stop it manually. It used to take no more than 5 seconds to perform a "replace" on the table with almost the same number of rows and columns. When this is running, I cannot access the table in any way (neither with query, nor in dbeaver etc). Sometimes when I abort the process (some time later when I see the process is not going to complete/gets stuck) the table no longer exists (as if it did the drop but not the create) and other times the table is "ok" but I can only see it when I abort the process, any idea what might be happening?

I have tried renaming the table, I put an abrupt break after 5 minutes, checking the dataframe before inserting it but nothing seems to work. it has happened with 2 tables in my database. it doesn't return any errors either, it just stays stuck.

0

There are 0 answers