Cloud Explainers

Why SQLite Is the Most Used Database in the World

Databases & SQL10 min videoPublished Nov 5, 2026

Why SQLite is the most used database in the world, for beginners, shown on a real Ubuntu laptop: Ana's tea shop keeps its stock in SQLite. There's no server to run, the whole database is one file, the library is small and a lookup takes microseconds, a crash in the middle of a write changes nothing, and it's public domain. Then its one real limit: one writer at a time, with a real "database is locked" error, and when to pick PostgreSQL or MySQL instead.

Why SQLite Is the Most Used Database in the World, the full picture: diagram of Ana's shop app, SQLite library, shop.db, shop.db-journal, sqlite3 tool, copy.db, One program, Files on Ana's laptop
The whole picture, from the video's recap.

The database you never installed

Your phone has hundreds of databases on it, and you never installed a database server. They're SQLite databases, and by the SQLite team's estimate, more than a trillion of them are in use.

SQLite databases in use today: figure of 1,000,000,000,000 over one trillion, by the SQLite team's estimate, source: sqlite.org/mostdeployed.html

It's in every Android phone and iPhone, every Mac and Windows computer, the big web browsers, and Python. So why does a database most people never hear about win? There are five reasons, and one of them is also its biggest limit. Ana will hit that limit for real near the end.

Where SQLite already runs: diagram of SQLite, Phones, Computers, Browsers, Languages

Here's a real question from Stack Overflow. Someone kept an SQLite database on one web server, and tried to open it from a second server, by its web address. It failed: unable to open database file. So they asked how to connect to the SQLite server. The surprise is, there is no SQLite server: the database is just a file on a computer's own disk, not a service at a web address. And that's reason one.

A real question: "connect to the SQLite server": diagram of Server two, Server one, open http://…/data.sqlite, unable to open database file, connect to the SQLite server?, there is no SQLite server

Reason 1: there's no server

What does a database server do? PostgreSQL and MySQL are servers: a separate program that runs all the time, listens on a network port, and answers your app's questions. SQLite isn't a program you run. It's a library: code inside your app, that reads and writes one file on disk, directly.

A database server vs SQLite: diagram of Your app, Database server, Its data folder, One file, Client and server, SQLite

Ana runs a small tea shop. On her laptop, she makes a table called teas, like a sheet in a spreadsheet, for her stock list, adds three teas, and reads them back. There was no install step, no user, no password, and no port.

laptop: Ana's terminal
sqlite3 shop.db "CREATE TABLE teas (name TEXT, price REAL, stock INTEGER);"
laptop: Ana's terminal
sqlite3 shop.db "INSERT INTO teas VALUES ('Sencha', 6.5, 40), ('Earl Grey', 5.0, 25), ('Oolong', 7.0, 12);"
laptop: Ana's terminal
sqlite3 -table shop.db "SELECT * FROM teas;"+-----------+-------+-------+
|   name    | price | stock |
+-----------+-------+-------+
| Sencha    | 6.5   | 40    |
| Earl Grey | 5.0   | 25    |
| Oolong    | 7.0   | 12    |
+-----------+-------+-------+

Now, what's running on this laptop? The ps command lists every running program: just three: a placeholder from our lab, the shell she's typing in, and ps itself. No database server, and no MySQL or PostgreSQL installed. The whole database is this one file, shop.db: eight thousand one hundred ninety-two bytes.

laptop: Ana's terminal
ps -e    PID TTY          TIME CMD
      1 ?        00:00:00 sleep
     14 pts/0    00:00:00 bash
     27 pts/0    00:00:00 ps
laptop: Ana's terminal
dpkg -l | grep -ci -e mysql -e postgres -e mariadb0
laptop: Ana's terminal
ls -l shop.db-rw-r--r-- 1 ana ana 8192 Nov  5 14:28 shop.db

So Ana's whole setup is this: her shop app, with the SQLite library inside it, and one file. Nothing to start, nothing to keep running, nothing to configure. That's why a phone app can just bring its own database along.

Reason 2: the database is one file

So what is that file, really? The file command recognises it: an SQLite 3 database, last written by SQLite version 3.45.1. And its first bytes spell it out: SQLite format 3.

laptop: Ana's terminal
file shop.dbshop.db: SQLite 3.x database, last written using SQLite version 3045001, file counter 2, database pages 2, cookie 0x1, schema 4, UTF-8, version-valid-for 2
laptop: Ana's terminal
head -c 15 shop.db; echoSQLite format 3

Any program with the library can open it. Ana's menu script is five lines of Python. It imports sqlite3, which comes with Python itself, connects to shop.db, and prints the prices. There's no driver to install, and no server address.

laptop: Ana's terminal
cat menu.pyimport sqlite3

db = sqlite3.connect("shop.db")
for name, price in db.execute("SELECT name, price FROM teas"):
    print(f"{name:<10} ${price:.2f}")
laptop: Ana's terminal
python3 menu.pySencha     $6.50
Earl Grey  $5.00
Oolong     $7.00

So the database travels like a document. Ana's app opens it, the sqlite3 tool opens the same file, and copy.db is a full backup she can keep anywhere. The format is the same on every computer, 32-bit or 64-bit, any processor, any operating system, so a file from a phone opens on a laptop as is.

And that file format is a long promise. The SQLite team plans to support it until 2050, and says files made today will still open decades from now. The US Library of Congress even lists SQLite as a recommended format for keeping data sets.

A file format built to last: cards of A long promise, Supported until 2050, Opens decades from now, Library of Congress

Reason 3: small and fast

How big is it? On Ubuntu, the whole library is 1.5 megabytes, with extras like full-text search built in. The command-line tool on top is about a third of a megabyte, 321 kilobytes. A lean build is under one megabyte, small enough for TV sets and car dashboards.

How big SQLite is, measured on Ubuntu 24.04: chart of SQLite library (with extras): 1.5 MB, sqlite3 tool (321 KB): 0.31 MB, A lean build: under 1 MB

Being inside your app also makes it fast. With a server, every query is a trip: your app sends it over a connection, the server works on it, and the rows come back. With SQLite, a query is a function call inside your own program, with no network in between.

Where one query goes: diagram of Database server, Your app, SQLite library, SELECT …, rows, No network trip: the library reads the file directly

Let's measure it. Ana's order table holds a hundred thousand orders, and her script looks up a hundred thousand of them, at random. Before we run it, guess: how long will that take? 1.10 seconds in total. About 11.0 microseconds per lookup, and that includes Python's own overhead.

laptop: Ana's terminal
ls -lh orders.db-rw-r--r-- 1 ana ana 1.8M Nov  5 14:28 orders.db
laptop: Ana's terminal
python3 lookups.py100,000 lookups in 1.10 seconds
11.0 microseconds each

How can something this small be a full SQL database? Here's what's inside the library. Your SQL text is compiled into bytecode, a small program, and a virtual machine runs it. A B-tree keeps the rows sorted by key, like the index of a book, so finding order number 50,000 takes a few page reads, not a read of the whole file. Pages are the fixed-size blocks the file is split into. The pager caches those pages, and handles the journal and the locks that keep the file safe. And the bottom layer reads the file through the operating system.

Inside the SQLite library: diagram of Your SQL, Compiler, Virtual machine, B-tree, Pager, OS interface

Reason 4: a crash can't half-save

What happens if a program dies in the middle of a write? Ana's restock script adds 100 to each tea's stock, all in one transaction. After two of the three teas, we kill it from a second window, with pkill -9, which ends it instantly, like a crash or a pulled plug. Notice the extra file while it ran: shop.db-journal.

laptop: Ana's two windows
sqlite3 -table shop.db "SELECT name, stock FROM teas;"+-----------+-------+
|   name    | stock |
+-----------+-------+
| Sencha    | 40    |
| Earl Grey | 25    |
| Oolong    | 12    |
+-----------+-------+
laptop: Ana's two windows
python3 restock.pyrestocked Sencha
restocked Earl Grey
laptop: Ana's two windows
pkill -9 -f restock.py
laptop: Ana's two windows
ls -l shop.db*-rw-r--r-- 1 ana ana 8192 Nov  5 14:28 shop.db
-rw-r--r-- 1 ana ana 4616 Nov  5 14:29 shop.db-journal

The script was killed after two teas. Guess: did two teas get restocked and one not? The stock is 40, 25 and 12, exactly what it was before the script started. All or nothing. The integrity check, a built-in test for a damaged file, says ok. Run the script to the end, and all three go up by 100.

laptop: Ana's terminal
python3 restock.pyrestocked Sencha
restocked Earl Grey
Killed
laptop: Ana's terminal
sqlite3 -table shop.db "SELECT name, stock FROM teas;"+-----------+-------+
|   name    | stock |
+-----------+-------+
| Sencha    | 40    |
| Earl Grey | 25    |
| Oolong    | 12    |
+-----------+-------+
laptop: Ana's terminal
sqlite3 shop.db "PRAGMA integrity_check;"ok
laptop: Ana's terminal
python3 restock.pyrestocked Sencha
restocked Earl Grey
restocked Oolong
done
laptop: Ana's terminal
sqlite3 -table shop.db "SELECT name, stock FROM teas;"+-----------+-------+
|   name    | stock |
+-----------+-------+
| Sencha    | 140   |
| Earl Grey | 125   |
| Oolong    | 112   |
+-----------+-------+

How does it manage that? A write happens in a fixed order. First, SQLite copies the original pages, the blocks it's about to change, into the journal, the undo file, and makes sure they're saved on disk. Only then does it overwrite those pages in shop.db. With the new pages safely in shop.db, deleting the journal is the commit. If a crash hits before that, the next program to open the database finds the journal and puts the old pages back. Here, the restock script died before the commit, so nothing changed.

How SQLite commits a write: diagram of SQLite, Journal, shop.db, 1. copy old pages, saved on disk, 2. write new pages, 3. delete journal, crash: old pages back, No commit, no change

And the code behind that is tested hard. The SQLite project has 590 times more test code than code in the library itself, including tests that simulate crashes and power failures in the middle of a write.

How hard SQLite is tested: figure of 590× more test code than library code, source: sqlite.org/testing.html (version 3.42.0)

Reason 5: free for anyone

Why can every company ship it? Because there's no license to sign. SQLite is in the public domain: anyone can use it, in any product, without paying or asking. Mozilla's Firefox, for example, keeps your bookmarks and history in one file, places.sqlite, in your Firefox profile. And Python and PHP ship it with the language.

Public domain: free for anyone, in anything: cards of Public domain, Any product, Firefox, Languages

The one job it's wrong for

So what's the limit we promised? In a second window, Ana opens the database and starts a write with BEGIN IMMEDIATE, which takes the write lock. She changes Sencha's price, but hasn't committed yet. Now the first window tries to add a tea. Error: database is locked. Reading still works: three teas. SQLite allows any number of readers, but only one writer at a time.

laptop: Ana's two windows
sqlite3 shop.dbSQLite version 3.45.1 2024-01-30 16:01:20
Enter ".help" for usage hints.
laptop: Ana's two windows
sqlite> BEGIN IMMEDIATE;
laptop: Ana's two windows
sqlite> UPDATE teas SET price = 7.5 WHERE name = 'Sencha';
laptop: Ana's two windows
sqlite3 shop.db "INSERT INTO teas VALUES ('Rooibos', 4.5, 30);"Error: stepping, database is locked (5)
laptop: Ana's two windows
sqlite3 shop.db "SELECT count(*) FROM teas;"3

Let's read that error. Stepping means SQLite was running the insert. Database is locked: another connection holds the write lock. And 5 is the code for busy, the same busy code any program using SQLite gets, whatever language it's written in.

Reading the error: diagram of Error: stepping, database is locked (5), stepping = running the statement, database is locked = another connection is writing, (5) = SQLITE_BUSY, Every program using SQLite gets the same code 5: busy

Writes usually take milliseconds, so writers just take turns. With a five-second timeout, this insert waits for its turn instead of failing. The moment the other window commits, it goes through: four teas.

laptop: Ana's two windows
sqlite3 -cmd ".timeout 5000" shop.db "INSERT INTO teas VALUES ('Rooibos', 4.5, 30);"
laptop: Ana's two windows
sqlite> COMMIT;
laptop: Ana's two windows
sqlite3 shop.db "SELECT count(*) FROM teas;"4

So when is SQLite the wrong choice? When many machines must write to the same data over a network, or lots of users write at the same instant. Then you want a database server, like PostgreSQL or MySQL: it listens on the network, and handles many writers. That's why the Stack Overflow question from the start had no easy answer: SQLite never listens on a network.

Many writers on a network: use a server: diagram of Web server 1, Web server 2, Web server 3, PostgreSQL or MySQL, Many machines

Here's the choice in one table. SQLite lives inside your app, as one file, with no setup, for one writer at a time. A server is its own program, with users and a port, for many writers. Phones, desktop apps, and a website on one machine: SQLite. Many servers sharing data: a database server.

SQLite or a database server?: comparison table of SQLite vs PostgreSQL / MySQL, Where it runs, The data, Setup, Writers at once, Best for

Recap

So: no server, one file, small and fast, safe when a program crashes, and free for anyone. That's why it's in nearly every device. Just remember: only one program can write at a time.

If SQLite makes sense now, a like helps YouTube show this to more beginners, and subscribing brings the next database demo to you.

Every command and output in this video came from a real run, on Ubuntu 24.04.5 LTS, with SQLite 3.45.1. Thanks for watching Cloud Explainers.

Sources

Demos: a stock Ubuntu 24.04 container on our own lab machine, standing in for a laptop; the tea shop and its stock are made up. Watch the full video on YouTube.

More videos

Databases & SQL11 min

How a NoSQL Database Like MongoDB Works

Python11 min

How to Fix Python pip error: externally-managed-environment

Databases & SQL9 min

How to Fix MySQL Too Many Connections Database Errors

Go (Golang)9 min

Golang Concurrency Will Finally Make Sense After This

AWS10 min

How Amazon S3 Works

Kubernetes10 min

How Kubernetes Works

Git10 min

How Git Works

Docker10 min

How to Fix Docker Port Already Allocated Errors

PostgreSQL10 min

How PostgreSQL Works

Git8 min

How to Fix Git Merge Conflicts

Linux9 min

How to Fix No Space Left on Device in Linux

Networking10 min

How the Internet Works

Databases & SQL9 min

SQL vs NoSQL: When Each One Wins

Auth (OAuth, JWT)8 min

How to Fix JWT Token Expired Errors (401 Unauthorized)

Claude & the Claude Developer Platform9 min

Claude API vs Claude Pro: Why Your Subscription Doesn't Include It

AI agent skills9 min

Why AI Agent Skills Beat Giant Prompts

Linux10 min

Linux Cron Jobs Will Finally Make Sense After This

Cybersecurity10 min

Security Logs Will Finally Make Sense After This

Cybersecurity8 min

How to Fix a Security Leak: An API Key Pushed to GitHub

DNS9 min

DNS Will Finally Make Sense After This

Cybersecurity9 min

Never Ignore a Security Update

Auth (OAuth, JWT)9 min

Two-Factor Authentication Will Finally Make Sense

Networking8 min

Never Expose a Database to the Internet

Cybersecurity10 min

SSH Keys vs Passwords: Which Is Safer for Security?

Linux10 min

The 5 Levels of Linux Boot: From Power On to Login

Networking12 min

The 5 Levels of Network Firewalls

Cybersecurity10 min

Password Security: Why Hackers Crack Weak Passwords

Linux9 min

Why Your Linux Server Runs Out of Memory

Networking10 min

HTTP vs HTTPS: What Actually Changes on Your Network

Linux12 min

Every Linux File Permission You Need to Know

Linux10 min

Linux Processes vs Threads: When Each One Wins

Networking11 min

The OSI Model Will Finally Make Sense After This

Git11 min

The 7 Levels of Git

Networking10 min

Every Network Troubleshooting Command You Need

Cybersecurity10 min

Hashing vs Encryption in Cybersecurity: When Each One Wins

Networking11 min

Why the Internet Ran Out of IP Addresses

Linux11 min

Linux Package Managers: apt vs Snap vs Flatpak

Python9 min

Why Python Is Slow (and When It Doesn't Matter)

Networking11 min

TCP vs UDP: When Each One Wins

Linux8 min

Stop Running Linux as Root (Do This Instead)

Linux11 min

Linux Users and Groups Will Finally Make Sense

Cybersecurity9 min

Why Phishing Beats Good Security (and How to Spot It)

Docker12 min

The 7 Levels of Docker

AI agents & MCP12 min

AI Agents Will Finally Make Sense After This

Git8 min

Stop Using git push --force (Use This Instead)

AI agent skills10 min

Agent Skills vs MCP: When Each One Wins

Networking12 min

Networking Will Finally Make Sense After This

Linux12 min

Every Linux Command You Actually Need

Cybersecurity12 min

The 7 Levels of Cybersecurity

System design12 min

Every System Design Concept You Need, in One Diagram

PostgreSQL10 min

Why PostgreSQL Ignores Your Index