I come to you because i cannot fix an issues with pandas.DataFrame.to_sql() method.
I've made the connection between my script and my database, i can send queries, but actually it's too slow for me.
I would like to find a way to improve the performance of my script on this. Maybe someone will find a solution?
Here is my code :
engine = sqlalchemy.create_engine(con['sql']['connexion_string'])
conn = engine.connect()
metadata = sqlalchemy.Metadata()
try :
if(con['sql']['strategy'] == 'NEW'):
query = sqlalchemy.Table(con['sql']['table'],metadata).delete()
conn.execute(query)
Sql_to_deploy.to_sql(con['sql']['table'],engine,if_exists='append',index = False,chunksize = 1000,method = 'multi')
elif(con['sql']['strategy'] == 'APPEND'):
Sql_to_deploy.to_sql(con['sql']['table'],engine,if_exists='append',index = False,chunksize = 1000,method = 'multi')
else:
pass
except Exception as e:
print(type(e))
It's working and too slow when i retire chunksize and method parameters,it's this moment where it's too slow (almost 3 minutes for 30 thousand lines). When i put these parameters, i get an sqlalchemy.exc.ProgrammingError...
thanks for your help !