I have a function that loops through and returns me 3 separate dataframe objects.
How do I put these 3 dataframe objects into 1 .db file with 3 separate tables?
The below code is what I am currently using. It loops through each of the items I have, do the needful and return me a Dataframe object that I can put to sql after that.
for each_item in items:
engine = create_engine("sqlite:///" + my_variable_database_name + ".db", echo=False)
connection = engine.connect()
pandas.DataFrame.to_sql(my_function(each_item), each_item, con=engine, if_exists="replace")
connection.close()
print(each_item + " has been completed successfully.")
print("All completed.")
How should I go about doing this?
to_sqlexport to database?.dbfiles, each with 1 table inside. I want to create 1.dbfile, with 3 tables inside.