I have data read from json and fed into an sqlite database with proper schema using sql-alchemy in python. (used pd.dataframe.to_sql() for this). I want the database dump (.sql file) of this database. is there any api in sql alchemy that would do this?
Assuming that you have a SQLAlchemy engine object associated with your SQLite database you can simply use Python's iterdump method like so:
con = engine.raw_connection()
with open('C:/Users/Gord/Desktop/dump.sql', 'w') as f:
for line in con.iterdump():
f.write('%s\n' % line)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With