Django integration with litestream, a a standalone streaming replication tool for SQLite.
Project description
django-litestream
django-litestream integrates Litestream, the SQLite replication tool, as a Django management command. The Litestream binary is bundled in platform-specific wheels — no manual download needed.
Table of Contents
Installation
The Litestream binary is bundled in platform-specific wheels and installed automatically alongside the Python wrapper. Supported platforms: Linux (x86_64, arm64, armv7, armv6) and macOS (x86_64, arm64).
pip install django-litestream
Add to INSTALLED_APPS:
INSTALLED_APPS = [
"django_litestream",
]
Custom binary path
If you prefer to use your own Litestream binary, set bin_path:
LITESTREAM = {
"bin_path": "/usr/local/bin/litestream",
}
When a platform-specific wheel is installed, the default bin_path of <venv>/bin/litestream works automatically — no configuration needed.
Configuration
# settings.py
LITESTREAM = {
"path_prefix": "", # prepended to replica paths
"bin_path": "./venv/bin/litestream", # custom binary path (optional)
"dbs": [{"path": "default"}], # databases to replicate
# ... any other Litestream config options
}
Configuration is dynamically generated from Django settings when you run commands — no YAML file needed. All Litestream configuration options are supported (e.g. logging, addr, mcp-addr, access-key-id, secret-access-key).
path_prefix is prepended to replica paths, useful when multiple projects share the same S3 bucket.
bin_path defaults to the bundled binary. Override it to use a system-installed Litestream or a custom installation.
dbs entries can reference Django database aliases ("default") instead of full file paths. If no replica is specified, an S3 replica is auto-generated using environment variables:
LITESTREAM_REPLICA_BUCKETorAWS_BUCKETLITESTREAM_ACCESS_KEY_IDorAWS_ACCESS_KEY_IDLITESTREAM_SECRET_ACCESS_KEYorAWS_SECRET_ACCESS_KEY
Configuration examples
Minimal — auto-generated S3 replica:
LITESTREAM = {
"dbs": [{"path": "default"}],
}
Multiple databases with path_prefix:
DATABASES = {
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DIR / "db.sqlite3"},
"cache": {"ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DIR / "cache.sqlite3"},
}
LITESTREAM = {
"path_prefix": "myproject",
"dbs": [
{"path": "default"}, # → myproject/db.sqlite3
{
"path": "cache",
"replica": { # explicit replica config
"type": "s3",
"bucket": "my-cache-bucket",
"path": "cache.sqlite3",
},
},
],
}
Generated config:
access-key-id: $LITESTREAM_ACCESS_KEY_ID
secret-access-key: $LITESTREAM_SECRET_ACCESS_KEY
dbs:
- path: /home/tobi/myproject/db.sqlite3
replica:
type: s3
bucket: $LITESTREAM_REPLICA_BUCKET
path: myproject/db.sqlite3
- path: /home/tobi/myproject/cache.sqlite3
replica:
type: s3
bucket: my-cache-bucket
path: cache.sqlite3
Commands
Run python manage.py litestream to see all available commands. Wherever db_path is required, you can use a Django database alias (e.g. "default") instead of the full file path.
litestream config
Display the current configuration generated from Django settings.
python manage.py litestream config
litestream databases
Lists all databases specified in the configuration. Same as upstream litestream databases.
python manage.py litestream databases
litestream ltx
Lists LTX (Litestream Transaction Log) files. Same as upstream litestream ltx.
python manage.py litestream ltx default
python manage.py litestream ltx -replica s3 default
python manage.py litestream ltx s3://mybkt.litestream.io/db
litestream replicate
Runs the replication server. Same as upstream litestream replicate.
python manage.py litestream replicate
python manage.py litestream replicate -exec "gunicorn myproject.wsgi:application"
python manage.py litestream replicate -once
python manage.py litestream replicate -force-snapshot
python manage.py litestream replicate -restore-if-db-not-exists
litestream restore
Recovers a database backup from a replica. Same as upstream litestream restore.
python manage.py litestream restore default
python manage.py litestream restore -o /tmp/restored.db default
python manage.py litestream restore -timestamp "2025-01-15T10:00:00Z" default
python manage.py litestream restore -f default # follow mode
python manage.py litestream restore -if-replica-exists default
litestream status
Reports local replication status.
python manage.py litestream status
python manage.py litestream status default
litestream sync
Forces immediate WAL-to-LTX sync for a database.
python manage.py litestream sync default
litestream mcp
Starts a standalone MCP (Model Context Protocol) server for AI assistant integration. Requires mcp-addr in configuration.
LITESTREAM = {
"mcp-addr": "127.0.0.1:3001",
}
python manage.py litestream mcp
The MCP server can also run alongside replication by adding mcp-addr and running replicate. Exposed tools: litestream_info, litestream_databases, litestream_status, litestream_ltx, litestream_restore, litestream_reset.
litestream wal / reset
python manage.py litestream wal default # list WAL files (deprecated, use ltx)
python manage.py litestream reset default # clear local state, force fresh snapshot
python manage.py litestream reset -dry-run default
litestream info / list
Daemon control commands — communicate with a running replicate daemon over the IPC socket.
python manage.py litestream info # daemon version, PID, uptime
python manage.py litestream info -json
python manage.py litestream list # list managed databases
litestream register / unregister
Dynamically add or remove databases from a running daemon.
python manage.py litestream register -replica s3://bucket/db default
python manage.py litestream unregister default
python manage.py litestream unregister -dry-run default
litestream start / stop
Pause or resume replication for a specific database on a running daemon.
python manage.py litestream stop default
python manage.py litestream start default
litestream version
Prints the Litestream binary version.
python manage.py litestream version
litestream verify
Verifies backup integrity by writing a verification row, waiting for replication, restoring the latest backup, and checking the row exists.
python manage.py litestream verify default
Steps:
- Inserts a unique row into
_litestream_verification - Waits 10 seconds for replication
- Restores the latest backup to a temporary location
- Verifies the row exists in the restored database
VFS Read Replicas
The VFS (Virtual File System) feature enables read-only access to database replicas in cloud storage without downloading the entire database. Pages are fetched on-demand.
VFS support is provided by the django-litestream-vfs package:
pip install django-litestream[vfs]
This installs:
django-litestream— wrapper + Litestream binarydjango-litestream-vfs— VFS extension + Python integration
Setup
1. Add to INSTALLED_APPS:
INSTALLED_APPS = [
"django_litestream",
"django_litestream_vfs", # loads VFS extension on startup
]
2. Configure VFS replicas:
# settings.py
from django_litestream_vfs import get_vfs_databases
LITESTREAM = {
"dbs": [{"path": "default"}],
"vfs": {
"prod_replica": "s3://mybucket/db.sqlite3",
"analytics_replica": "s3://analytics/db.sqlite3",
},
}
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
},
**get_vfs_databases(), # adds prod_replica and analytics_replica
}
3. Use VFS replicas:
from myapp.models import User
users = User.objects.using("prod_replica").all()
Supported storage backends
| URL format | Provider |
|---|---|
s3://bucket/path |
Amazon S3 |
gcs://bucket/path |
Google Cloud Storage |
abs://container/path |
Azure Blob Storage |
Architecture
django-litestream-vfs is a separate package that depends on django-litestream. The VFS extension (.so/.dylib) is bundled in platform-specific wheels and installed alongside the main Litestream binary. The extension is loaded once per process by VfsConfig.ready() and made available to all SQLite connections via vfs=litestream.
VFS replicas are read-only. Writes will return errors. Only x86_64 and arm64 architectures are supported for the VFS extension.
License
MIT — see LICENSE.txt. The bundled Litestream binary uses the Apache 2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_litestream-0.5.11.tar.gz.
File metadata
- Download URL: django_litestream-0.5.11.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c668ee0ffc77975d11b8136e4be74cc119f88188dc90fe8f9bf0340e3d478379
|
|
| MD5 |
d0d37800894ea82c8628661a0b616ac8
|
|
| BLAKE2b-256 |
a134c776ab3f9b1bf0b5cfd67b605442119dab5bc6284ce464bde0e7ee07ed2f
|
Provenance
The following attestation bundles were made for django_litestream-0.5.11.tar.gz:
Publisher:
publish.yml on Tobi-De/django-litestream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_litestream-0.5.11.tar.gz -
Subject digest:
c668ee0ffc77975d11b8136e4be74cc119f88188dc90fe8f9bf0340e3d478379 - Sigstore transparency entry: 1743703699
- Sigstore integration time:
-
Permalink:
Tobi-De/django-litestream@fbe5242abe153223b5605974ff4d56009d3a15be -
Branch / Tag:
refs/tags/v0.5.11 - Owner: https://github.com/Tobi-De
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fbe5242abe153223b5605974ff4d56009d3a15be -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_litestream-0.5.11-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.whl.
File metadata
- Download URL: django_litestream-0.5.11-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.whl
- Upload date:
- Size: 37.7 MB
- Tags: Python 3, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c4c069af906e39512c29080f775f1907a3acf7fe152f1cb3990ff0d1ddc2550
|
|
| MD5 |
40094e5bd9e932d4f898ec9aebf0c61e
|
|
| BLAKE2b-256 |
9e24c753fe10a1eb1215032f62bd5266cb4c984668a900463aa5e9a189eba7eb
|
Provenance
The following attestation bundles were made for django_litestream-0.5.11-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.whl:
Publisher:
publish.yml on Tobi-De/django-litestream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_litestream-0.5.11-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.whl -
Subject digest:
6c4c069af906e39512c29080f775f1907a3acf7fe152f1cb3990ff0d1ddc2550 - Sigstore transparency entry: 1740072144
- Sigstore integration time:
-
Permalink:
Tobi-De/django-litestream@fbe5242abe153223b5605974ff4d56009d3a15be -
Branch / Tag:
refs/tags/v0.5.11 - Owner: https://github.com/Tobi-De
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fbe5242abe153223b5605974ff4d56009d3a15be -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_litestream-0.5.11-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.whl.
File metadata
- Download URL: django_litestream-0.5.11-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.whl
- Upload date:
- Size: 34.9 MB
- Tags: Python 3, musllinux: musl 1.1+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
602f1820e026079d6dfc3868e1ef182e49760de1f21304ca5ff5261fa8a73a67
|
|
| MD5 |
83e778e2bd9d9b24f530fd042b1e5f78
|
|
| BLAKE2b-256 |
28c94cbdf10f500d09ee3f34ae97546a6e49a89d3559b7872120eacf2b038df8
|
Provenance
The following attestation bundles were made for django_litestream-0.5.11-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.whl:
Publisher:
publish.yml on Tobi-De/django-litestream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_litestream-0.5.11-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.whl -
Subject digest:
602f1820e026079d6dfc3868e1ef182e49760de1f21304ca5ff5261fa8a73a67 - Sigstore transparency entry: 1740018497
- Sigstore integration time:
-
Permalink:
Tobi-De/django-litestream@b4c3da8c1e79de9dba95fb602214e24970d759bc -
Branch / Tag:
refs/tags/v0.5.11 - Owner: https://github.com/Tobi-De
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c3da8c1e79de9dba95fb602214e24970d759bc -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_litestream-0.5.11-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: django_litestream-0.5.11-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 36.2 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b639235cb594b70b20c543d573ff03b5f3d1704ffad35e68a01a59765c5b7d51
|
|
| MD5 |
3b6da0832963bdc4b7cb3c85fa8359de
|
|
| BLAKE2b-256 |
0ae154d28c66d4472f96f849888925fe8e799b368ddfaec97ed14d9bf290a570
|
Provenance
The following attestation bundles were made for django_litestream-0.5.11-py3-none-macosx_11_0_arm64.whl:
Publisher:
publish.yml on Tobi-De/django-litestream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_litestream-0.5.11-py3-none-macosx_11_0_arm64.whl -
Subject digest:
b639235cb594b70b20c543d573ff03b5f3d1704ffad35e68a01a59765c5b7d51 - Sigstore transparency entry: 1740018492
- Sigstore integration time:
-
Permalink:
Tobi-De/django-litestream@b4c3da8c1e79de9dba95fb602214e24970d759bc -
Branch / Tag:
refs/tags/v0.5.11 - Owner: https://github.com/Tobi-De
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c3da8c1e79de9dba95fb602214e24970d759bc -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_litestream-0.5.11-py3-none-macosx_10_9_x86_64.whl.
File metadata
- Download URL: django_litestream-0.5.11-py3-none-macosx_10_9_x86_64.whl
- Upload date:
- Size: 38.8 MB
- Tags: Python 3, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d447a587c0b8fdcd011bf823efffbb90a1d67b21450bbaec24b0471643496a7
|
|
| MD5 |
0ffdcfb6269f6b97c20358939e634e2d
|
|
| BLAKE2b-256 |
784617bbd4f95c949acbf02c8474cc171dfb5d9d552aa41c9dcafa327d84baee
|
Provenance
The following attestation bundles were made for django_litestream-0.5.11-py3-none-macosx_10_9_x86_64.whl:
Publisher:
publish.yml on Tobi-De/django-litestream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_litestream-0.5.11-py3-none-macosx_10_9_x86_64.whl -
Subject digest:
3d447a587c0b8fdcd011bf823efffbb90a1d67b21450bbaec24b0471643496a7 - Sigstore transparency entry: 1740018474
- Sigstore integration time:
-
Permalink:
Tobi-De/django-litestream@b4c3da8c1e79de9dba95fb602214e24970d759bc -
Branch / Tag:
refs/tags/v0.5.11 - Owner: https://github.com/Tobi-De
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c3da8c1e79de9dba95fb602214e24970d759bc -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_litestream-0.5.11-py3-none-any.whl.
File metadata
- Download URL: django_litestream-0.5.11-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1cc5686804835d4b144fad72ddbc9313bbeeb3b9363d268d1548a9d0d7563e4
|
|
| MD5 |
ddabbd6eeafc6fe2f1ef1747d8245cfc
|
|
| BLAKE2b-256 |
bc57bf2c6788294f32ec9524e9047179d06ff6fb3d79a50dcf0310dc460a1453
|
Provenance
The following attestation bundles were made for django_litestream-0.5.11-py3-none-any.whl:
Publisher:
publish.yml on Tobi-De/django-litestream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_litestream-0.5.11-py3-none-any.whl -
Subject digest:
d1cc5686804835d4b144fad72ddbc9313bbeeb3b9363d268d1548a9d0d7563e4 - Sigstore transparency entry: 1740018486
- Sigstore integration time:
-
Permalink:
Tobi-De/django-litestream@b4c3da8c1e79de9dba95fb602214e24970d759bc -
Branch / Tag:
refs/tags/v0.5.11 - Owner: https://github.com/Tobi-De
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4c3da8c1e79de9dba95fb602214e24970d759bc -
Trigger Event:
push
-
Statement type: