SQLite Introduction
Why Use a Database?
Most programs need to keep data: users, products, orders, scores or notes.
A database keeps the data in tables, and lets you find, sort and change it quickly. You talk to the database with SQL, the language of databases.
What is SQLite?
SQLite is a database engine. It is a small program library that reads and writes to a database.
- SQLite keeps a whole database, with all its tables, in a single file
- SQLite needs no server, and nothing to set up
- SQLite is free, and the source code is in the public domain
- SQLite is the most widely used database engine in the world
SQLite Needs No Server
Database systems like MySQL and PostgreSQL run as a separate server program. Your program sends SQL to the server, and the server reads and writes the data.
SQLite works in a different way. The database engine is a part of your program, and it reads and writes the database file directly. There is no server to install, start or configure.
Who Uses SQLite?
You probably use SQLite every day without knowing it:
- Android phones and iPhones use SQLite to store contacts, messages and app data
- Web browsers like Chrome, Firefox and Safari use SQLite to store history and bookmarks
- Python comes with SQLite, in the
sqlite3module - Many desktop programs and devices use SQLite as their file format
When to Use SQLite
SQLite is a great choice for:
- Apps for phones and computers
- Small and medium websites
- Data analysis and testing
- Learning SQL
A database server, like MySQL, is a better choice when many users write to the same database at the same time, over a network.
| SQLite | MySQL | |
|---|---|---|
| Server | No server | Runs as a server |
| Database | One file | Managed by the server |
| Setup | Nothing to set up | Install and configure the server |
| Writing | One writer at a time | Many writers at the same time |
| Data types | Flexible | Strict |
SQLite and SQL
SQLite uses SQL, like other databases. Most of the SQL you learn here works in other databases too.
This tutorial shows the SQLite way of doing things, and the features that are special for SQLite.