Skip to main content

sqlite-utils

PyPI Changelog Python 3.x Tests Documentation Status codecov License discord

Python CLI utility and library for manipulating SQLite databases.

Some feature highlights

Upgrading from sqlite-utils 3.x? See the 4.0 upgrade guide.

Read more on my blog, in this series of posts on New features in sqlite-utils and other entries tagged sqlite-utils.

Installation

pip install sqlite-utils

Or if you use Homebrew for macOS:

brew install sqlite-utils

Using as a CLI tool

Now you can do things with the CLI utility like this:

$ sqlite-utils memory dogs.csv "select * from t"
[{"id": 1, "age": 4, "name": "Cleo"},
 {"id": 2, "age": 2, "name": "Pancakes"}]

$ sqlite-utils insert dogs.db dogs dogs.csv --csv
[####################################]  100%

$ sqlite-utils tables dogs.db --counts
[{"table": "dogs", "count": 2}]

$ sqlite-utils dogs.db "select id, name from dogs"
[{"id": 1, "name": "Cleo"},
 {"id": 2, "name": "Pancakes"}]

$ sqlite-utils dogs.db "select * from dogs" --csv
id,age,name
1,4,Cleo
2,2,Pancakes

$ sqlite-utils dogs.db "select * from dogs" --table
  id    age  name
----  -----  --------
   1      4  Cleo
   2      2  Pancakes

You can import JSON data into a new database table like this:

$ curl https://api.github.com/repos/simonw/sqlite-utils/releases \
    | sqlite-utils insert releases.db releases - --pk id

Or for data in a CSV file:

$ sqlite-utils insert dogs.db dogs dogs.csv --csv

sqlite-utils memory lets you import CSV or JSON data into an in-memory database and run SQL queries against it in a single command:

$ cat dogs.csv | sqlite-utils memory - "select name, age from stdin"

See the full CLI documentation for comprehensive coverage of many more commands.

Using as a library

You can also import sqlite_utils and use it as a Python library like this:

import sqlite_utils
db = sqlite_utils.Database("demo_database.db")
# This line creates a "dogs" table if one does not already exist:
db["dogs"].insert_all([
    {"id": 1, "age": 4, "name": "Cleo"},
    {"id": 2, "age": 2, "name": "Pancakes"}
], pk="id")

Check out the full library documentation for everything else you can do with the Python library.

  • Datasette: A tool for exploring and publishing data
  • csvs-to-sqlite: Convert CSV files into a SQLite database
  • db-to-sqlite: CLI tool for exporting a MySQL or PostgreSQL database as a SQLite file
  • dogsheep: A family of tools for personal analytics, built on top of sqlite-utils

Metadata

Release files for sqlite-utils 4.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlite-utils 4.2.2
File Size Uploaded Provenance Actions
sqlite_utils-4.2.2.tar.gz 322.8 kB Without provenance Details for sqlite_utils-4.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlite-utils 4.2.2
File Interpreter ABI Platform Actions
sqlite_utils-4.2.2-py3-none-any.whl Python 3 none any Details for sqlite_utils-4.2.2-py3-none-any.whl

Total release size: 424.4 kB

Release files / sqlite_utils-4.2.2.tar.gz

Download URL sqlite_utils-4.2.2.tar.gz
Size 322.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5c54dc4d77260b44e8d0ccf4461c321c40ca1451dd6b6a63398ed058722aff13
BLAKE2b-256 checksum
How to use checksums
ca02e627be6718f4fe6afc16c803d76efd2cddee47d8a929ca6ba244d8f98427
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / sqlite_utils-4.2.2-py3-none-any.whl

Download URL sqlite_utils-4.2.2-py3-none-any.whl
Size 101.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e92aa6c2bcefa1877cbd56e8da6fe3924ca5b45954f98e7d738c49d19325fa0d
BLAKE2b-256 checksum
How to use checksums
c759ce540c9709911e7e120419ceea3a39c79449be620ac3902dfae4a7fd9cc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for sqlite-utils 4.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.2.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page