I was looking everywhere here, I can not find a way to perform a simple single line insert without waiting for respond, just keep executing next line :
engine = sqlalchemy.create_engine('postgresql psycopg2://' username ':' password '@/' database "?host=" path)
df.to_sql('queries', engine, if_exists='append', index=False)
This runs on a server to save some analytics to Postgresql, and i don't want to wait for respond, I also don't care if it failed here and there.
It is super important to me, to keep executing right after, and spend no time on this.
How to do this ?
CodePudding user response:
From the documentation df.to_sql() does not support what you want. But there are some workarounds you can do:
- Create a function that uses threading to insert this df to your db. Check this answer.
- You can use async calls and sqlalchemy but you would need to map this dataframe to an object or something that sqlalchemy can work with.