Setting up a SQLite database in Python
SQLite (pronounced Sequel Lite) is a lightweight disk-based database that doesn't require a separate server process and uses a modified version of the SQL query language to access the data. The entire database is saved in a single file and can be used for internal data storage. It is also possible to make a prototype of an application using SQLite and then port the code to work with a larger database with minimal modifications. The Python standard library has a module called sqlite3
included, which is intended to work with this database. This module is SQL interface-compliant with DB-API 2.0.
Note
You can find more information and the full API reference for the SQLite3 module on its official website: https://docs.python.org/2/library/sqlite3.html.
Next is an example on how to use the sqlite3
module to create a SQLite database to store and retrieve some data. We will go through the code, statement by statement, and analyze what each statement does...