Now that you understand a little about SQL and relational databases, let’s discuss SQLite. SQLite is a lightweight disk-based database, meaning we store data on a hard drive or another type of local storage. Many people use SQLite because it doesn’t require a separate server process, so programmers can edit or retrieve the data using a nonstandard form of the SQL query language. It can also be useful to prototype an application and then transfer the code to a larger database, such as Oracle or PostgreSQL. Additionally, applications such as Python can use SQLite for internal data storage.

How can Python access SQLite?

Thanks to Python’s Database-API (DB-API 2.0), we can connect Python to RDBMS (Relational Database Management System) like SQLite. The DB-API allows a Python user to access a database file, which is the file type for SQL. Using the module sqlite3, we can create, read, update, and delete the data in the SQLite relational database within the Python environment. Below, shows how we import sqlite3 into our Python file.

# Import the SQLite module import sqlite3
Why use Python?

Why use Python to access SQLite? Firstly, you’ve already spent hours learning and understanding the Python language. Without needing an additional application, you can utilize the SQL database storage system using a Python script.

Secondly, Python is excellent at data manipulation. Once you pull the SQLite data into your Python environment, you can analyze, visualize, change, and test this data all you want! Python has many great data manipulation libraries such as pandas, numpy, matplotlib, and more. Together, SQLite and Python make a great team!

To your right is an image that can help explain how Python and SQLite function together. Simply hover over the objects to learn more!

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?