How To Put CSV Data Into An SQLite DB With Python #pythonbeginners #sqlite #sqlite3



How To Put CSV Data Into An SQLite DB With Python #pythonbeginners #sqlite #sqlite3

How To Put CSV Data Into An SQLite DB With Python #pythonbeginners #sqlite #sqlite3

Storing data in flat files can be OK. But for a lot of applications you really need a database.

Python provides a neat little database out of the box called SQLite.

This video goes through a simple script that puts spreadsheet data into one of these SQLite databases.

First, we import our spreadsheet data (in CSV format) using Pandas. From that Pandas data frame we prepare the data ready for injection into our SQL database.

Then, the script establishes a connection to the database (creating it if it doesn’t exist), and creates a cursor object. The cursor is the thing that allows us to work with the database (reading, writing and deleting data).

After that, all that remains is to actually inject the data into our database and we are done!

As a final step, we check to see it has worked by using a database browser (DB Browser) to view the contents of our database.

SQLite Python docs: https://docs.python.org/3/library/sqlite3.html
SQL cheat sheet: https://www.sqlitetutorial.net/sqlite-cheat-sheet/
DB Browser for SQLite: https://sqlitebrowser.org/
Article breaking down databases and spreadsheets: https://365datascience.com/tutorials/sql-tutorials/database-vs-spreadsheet/