Databases & Storage

sqlite-utils

Turns a messy CSV file into a real, searchable database with a single command.

Install it: pip install sqlite-utils

What does it do?

sqlite-utils is both a command-line tool and a Python library for creating and manipulating SQLite databases, the small, file-based database format that doesn’t need a separate server running, just a single file on your computer. It can look at a messy CSV file or a pile of JSON data, automatically guess a sensible table structure, and load it into a real, queryable database in seconds, something that would otherwise take real database knowledge to set up manually. Because it’s usable both as a quick command typed in a terminal and as a Python library inside a bigger script, it fits equally well into a five-second one-off task and a larger automated pipeline. It’s built with an emphasis on making data exploration and transformation genuinely fast and low-friction.

See it in action

This code creates a small searchable database file, adds two people’s records to it, and then prints every record it just stored.

import sqlite_utils

db = sqlite_utils.Database("data.db")
db["people"].insert({"name": "Alice", "age": 30})
db["people"].insert({"name": "Bob", "age": 25})

for row in db["people"].rows:
    print(row)

Why would a non-developer care?

A lot of interesting analysis starts with data trapped in an awkward format — a spreadsheet export, a pile of JSON files, scraped web data — that’s hard to search or combine without real database setup work. sqlite-utils removes nearly all of that friction, turning ‘I have a messy file’ into ‘I have a searchable database’ almost instantly. That matters especially for journalists, researchers, and analysts who need to work with data quickly without becoming database administrators first.

Real-world examples

sqlite-utils is a core part of the Datasette project, an increasingly popular tool for publishing and exploring datasets that journalists and open-data researchers use to make government and public records searchable online. It’s commonly used in data journalism workflows to quickly turn scraped or leaked data dumps into something queryable. Without a tool like it, that same process would mean manually designing a database schema and writing custom import scripts for every new dataset.

Who uses it

Data journalists, researchers, and analysts who need to quickly turn messy files into a real, searchable database without formal database training.

How it compares to alternatives

Compared to setting up SQLAlchemy or writing raw SQL by hand, sqlite-utils automates away most of the manual schema design work for common cases. pandas can also load and manipulate similar data but keeps it in memory rather than a persistent, queryable database file. For quick, disposable data exploration, sqlite-utils often gets you to a useful result faster than either.

Fun fact

sqlite-utils was created by Simon Willison, co-creator of the Django web framework, as part of his broader Datasette project for making data more publicly accessible.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries