Skip to content
Advertisement

Union statement statement in SQLAlchemy

I have multiple large csv files that I want to merge and store the final table in a database for using in Pandas in the future. I read them all using Pandas and store them as separate but similar tables into a Sqlite database.

I want to merge the rows (vertically) by a SQL string and then use them in pandas for more analyses. I was wondering if this is a good practice to go back and forth between pandas and SQL for when we deal with large files and have limited memory (16GB) ?

Also my code gives me an error and I was unsure if there is a syntax issue or something more significant that I missing here.

Advertisement

Answer

That’s not the correct syntax for inserting the results of a query into another table.

It’s INSERT INTO tablename SELECT ...

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement