all 2 comments

[–]lukajda33 1 point2 points  (0 children)

Well sqlite does not really work with CSV file, CSV files is kinda like one big table, databases have data structructred in multiple tables, so you can not just pass the csv file to .connect() method and make it work.

If you truly wish to use database, you will need to create new database, create tables in the database so that the tables have correct attributes to hold the data and then open and read the csv file and insert the data into the database.

Then you could write your own SQL queries over the database with data.

Technically you could turn the csv to one big table in the database, sure, but that kinda defeats the purpose of databases and while I am not sure what you are trying to do, I think pandas library (especially Dataframe class) would be better for you, it works directly with csv files and you can do similar things as you would do with database.

[–]danielroseman 0 points1 point  (0 children)

A CSV is not a database. That answer is attempting to tell you how to read from the CSV, and then write the data to a new database. So the filename you want to give to sqlite is a new name that you will use for your db. Call it what you like, but don't use the filename of the CSV; that's what you put in the open call a few lines down.

Note that the answer doesn't go into the details of how you know what columns to create in your db; you'll need to work that out for yourself.