SQLite: Portable Database
A database in a single file.
Master the most widely deployed database engine in the world, stored entirely within a single, portable file.
The Database in a Box.
A .sqlite file is a computer file that holds data. But it is not a normal file. It is a complete, fully working database packed into one single item.
The "One File" Rule
Usually, saving a lot of information means installing big software on a computer. SQLite does not do this. It puts tables, rules, and data into one normal file that you can copy, paste, and email.
Easy to Copy
Want to back up your data? Just copy the single file. That is it.
Easy to Share
You can send a `.sqlite` file over email or chat, just like a picture.
Ready to Use
Programs can read this file directly. No setup is needed.
How is it Different?
Normal Database
- Requires a big separate program to run.
- You must create a username and password.
- Uses a network to send data back and forth.
- Hard to set up for simple apps.
SQLite
- It is just a file on your disk.
- No passwords. If you can open the file, you have the data.
- Reads data instantly from the local computer.
- Built right into the app. Zero setup.
Where Does It Live?
You probably have hundreds of `.sqlite` files on your devices right now. They run quietly in the background of almost everything you use.
Mobile Apps
Your contacts, text messages, and notes on your phone.
Web Browsers
Your bookmarks, search history, and saved passwords.
Computer Tools
Music players, photo editors, and local software.
Smart Devices
Smart TVs, car screens, and thermostats.
Looking Inside the File
Inside a `.sqlite` file, data is not a messy pile. It is perfectly arranged into grids called Tables. Tables have Columns (top) and Rows (across).
| ID | Name | City | Active |
|---|---|---|---|
| 1 | John Smith | New York | YES |
| 2 | Anna Lee | London | NO |
| 3 | Tom Baker | Sydney | YES |
Talking to the Data
To get answers from a `.sqlite` file, we use a language called SQL (Structured Query Language).
You type a command, and the file instantly gives you the exact rows you asked for. It is like a search engine for your data.
SELECT Name, City FROM customers WHERE Active = 'YES';
Tom Baker | Sydney
Why Developers Love It
Extremely Fast
Because the file lives directly on the computer, reading data takes almost zero time.
Very Safe
If the power goes out while saving, SQLite fixes itself so data is never broken.
100% Free
It is free for anyone to use. Big companies and solo builders use the exact same free tool.
Tiny Size
The tool that runs the database is so small, it takes up less space than a single photo.
When To Avoid SQLite
SQLite is amazing, but it has rules. It is not built for everything. Do NOT use it if:
Many people write data at the exact same second.
You are building a giant website like Facebook or Amazon.
You have more data than can fit on one computer drive.
If you need these things, you must use a big server database instead.
How to Look Inside a File
You cannot open a `.sqlite` file with a text editor like Notepad. It will just look like gibberish. You need a special viewing tool.
Download a Viewer
A popular, free tool is called DB Browser for SQLite. It works on Windows, Mac, and Linux.
Open the File
Open the tool, click "Open Database", and choose your `.sqlite` file from your computer.
Browse Data
Click the "Browse Data" tab to see all your tables neatly lined up like a spreadsheet.
The 5 Things You Can Store
SQLite keeps things incredibly simple. Instead of having dozens of complicated data types, it sorts everything you save into just five basic categories.
TEXT
Words, sentences, or letters.
INTEGER
Whole numbers like 42 or -5.
REAL
Decimals like 3.14 or 0.99.
BLOB
Raw files, like an image.
NULL
Empty. Absolutely nothing.
Born on a Battleship
In the year 2000, a programmer named D. Richard Hipp was working for the US Navy on a guided missile destroyer.
The heavy, complex database software they were using kept breaking and was too hard to install on the ship's computers. He decided to write a tiny, foolproof database that didn't need any installation at all. That tool became SQLite, now the most widely used database in the entire world.
Year 2000
First Release
Is the Data Safe from Hackers?
Out of the Box
Normally, a `.sqlite` file is totally open. It is like a text document. If someone steals your laptop and finds the file, they can open it and read everything inside immediately.
How We Fix It
Programmers fix this using an extra tool like SQLCipher. It scrambles the whole file and wraps it in a heavy password. Without the password, the file looks like useless junk data to a hacker.
The Speed Secret: Indexes
If your file has a million users, searching for "John" means scanning one million rows. That takes time. To make it instant, we use an Index.
Without an Index
Like reading a 1,000-page book word-by-word just to find one specific name. Very slow.
With an Index
Like jumping straight to the back of the book, finding the name in the alphabetical index, and going right to page 42. Instant.
-- How to make an index: CREATE INDEX find_name ON customers (Name);
What Languages Talk to It?
Because it is the most used database in the world, almost every coding language has a built-in tool to read and write to `.sqlite` files. You do not have to install extra adapters.
The Hacker Way: The Terminal
You do not need a visual app with buttons to look at your data. Programmers often just open their computer's black text screen (the Command Line).
By typing sqlite3 followed by the file name, they can enter commands using only the
keyboard. It is much faster once you know how to type the rules.
> sqlite3 app_data.sqlite SQLite version 3.39.0 Enter ".help" for usage hints. sqlite> .tables customers orders products sqlite> SELECT count(*) FROM customers; 1042 sqlite>
Busting SQLite Myths
"It is only for testing apps, not for real users."
False. Apple uses it to store your iPhone texts. Google uses it in Chrome. It handles heavy, real-world work perfectly.
"It can only hold a very small amount of data."
False. A single `.sqlite` file can hold up to 281 Terabytes of data. That is more space than most modern computers even have.
Backing Up is Too Easy
Method 1: Just Copy It
Because it is a single normal file, you literally just Right-Click -> Copy, and then Paste it onto a USB drive. Done. Your backup is safe.
Method 2: Export to Text
Programmers can type a special command called .dump. This
turns the whole database into a giant text document of pure SQL code, making it readable by
humans.
Step-by-Step: Saving a Note
When you tap "Save" on a notes app on your phone, here is exactly what happens with SQLite in the background in less than a second.
You type "Buy Milk" and hit save.
The app writes a hidden SQL INSERT command.
SQLite opens the file and locks it for safety.
Data is written to the file forever. File unlocks.
The "Local-First" Future
For the last ten years, every app forced you to save data to the "Cloud" (someone else's server). But what happens when you lose internet? The app stops working.
Now, the best programmers are going back to "Local-First". They use SQLite to save all your data directly on your phone or laptop first. This means the app opens instantly with zero loading screens, and works perfectly on an airplane without Wi-Fi.
Zero Loading Screens.
Works Offline.
The Quick Cheat Sheet
A self-contained database in one file.
No. It runs directly on the device.
SQL (Structured Query Language).
Mobile apps, browsers, and local tools.
100% Free forever.
.sqlite, .db, .sqlite3
More in this series
Master more skills with other tutorials from the Data Engineering series.
Data Engineering
- DB: Generic Database File: The universal data container.
- SQLite: Portable Database: A database in a single file.
- SQL: Structured Query Language: The language of data.
- CSV: Comma-Separated Values: The universal data exchange format.
Spreadsheets
- NUMBERS: Apple Numbers Spreadsheet: Visual data storytelling.
- XLSM: Macro-Enabled Spreadsheet: Excel with automation power.
- ODS: OpenDocument Spreadsheet: The open spreadsheet standard.
- XLS: Legacy Excel Spreadsheet: The foundation of digital spreadsheets.
- XLSX: Modern Excel Spreadsheet: The data powerhouse.
Presentations
- ODP: OpenDocument Presentation: The open standard for slides.
- PPT: Legacy Presentation: The classic slide deck format.
- PPTX: Modern Presentation: The gold standard for slide decks.
Word Processing
- WPS: WPS Office Document: The lightweight contender.
- PAGES: Apple Pages Document: The designer's word processor.
- ODT: OpenDocument Text: The open text standard.
- DOC: Legacy Word Document: The classic document format.
- DOCX: Modern Word Document: The standard for office documents.
- RTF: Rich Text Format: The universal translator.
Digital Publishing
- TEX: LaTeX Document: The mathematician's choice.
- PDF: Portable Document Format: The digital paper standard.
Software Engineering
- TSX: TypeScript XML: The modern web component.
Markdown & Text
- MD: Markdown: The programmer's writer.
- TXT: Plain Text: The simplest file in the world.