Skip to main content

Django integration with litestream, a a standalone streaming replication tool for SQLite.

Project description

django-litestream

PyPI - Version PyPI - Python Version PyPI - Versions from Framework Classifiers MIT License

Django integration for Litestream, the SQLite replication tool. The Litestream binary is bundled in platform-specific wheels — no manual download needed. All upstream commands are available as python manage.py litestream <command>.

Note: This package tracks Litestream's upstream version. The initial release is 0.5.11, matching Litestream v0.5.11. Wrapper-only fixes (no Litestream update) use PEP 440 post-releases like 0.5.11.post1.

Installation

pip install django-litestream

Add to INSTALLED_APPS:

INSTALLED_APPS = [
    "django_litestream",
]

The binary is installed automatically on supported platforms (Linux/macOS x86_64 & arm64). On unsupported platforms, set a custom path:

LITESTREAM = {
    "bin_path": "/usr/local/bin/litestream",
}

Configuration

Configuration is generated dynamically from Django settings — no YAML file needed.

# settings.py
LITESTREAM = {
    "path_prefix": "",      # prepended to S3 replica paths
    "bin_path": "...",      # custom binary path (optional)
    "dbs": [                # databases to replicate
        {"path": "default"},
    ],
}

All Litestream config options are supported (addr, logging, mcp-addr, access-key-id, etc.).

Database aliases

Use Django database aliases instead of file paths wherever db_path is required:

python manage.py litestream restore default        # instead of /path/to/db.sqlite3
python manage.py litestream sync default

Auto-generated replicas

If no replica is specified for a database, an S3 replica is auto-generated using environment variables:

LITESTREAM = {
    "dbs": [{"path": "default"}],
}
# Uses: LITESTREAM_REPLICA_BUCKET, LITESTREAM_ACCESS_KEY_ID, LITESTREAM_SECRET_ACCESS_KEY

Explicit replica config:

LITESTREAM = {
    "dbs": [
        {
            "path": "default",
            "replica": {
                "type": "s3",
                "bucket": "my-bucket",
                "path": "db.sqlite3",
            },
        },
    ],
}

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": {
                "type": "s3",
                "bucket": "my-cache-bucket",
                "path": "cache.sqlite3",
            },
        },
    ],
}

Custom commands

These commands are unique to django-litestream — they don't exist in upstream Litestream.

litestream config

Display the generated configuration in YAML format.

python manage.py litestream config

Useful for verifying your setup before running replication.

litestream verify

Checks backup integrity end-to-end: writes a verification row, waits for replication, restores the latest backup, and confirms the row exists.

python manage.py litestream verify default

Upstream commands

All Litestream commands are exposed as management commands. Run python manage.py litestream to see the full list. Key notes:

  • replicate: Run in production via a process manager. Use -exec to wrap your application server.
  • restore: Supports -timestamp, -generation, -index for point-in-time recovery.
  • Daemon control (info, list, register, unregister, start, stop): Communicate with a running replicate daemon over IPC.

The only difference from upstream is that Django database aliases work anywhere db_path is expected.

VFS Read Replicas

Read-only access to cloud-stored replicas without downloading the entire database. Pages are fetched on-demand.

pip install django-litestream[vfs]

This installs both django-litestream and django-litestream-vfs (the VFS extension and Python integration).

Setup

# settings.py
from django_litestream_vfs import get_vfs_databases

LITESTREAM = {
    "dbs": [{"path": "default"}],
    "vfs": {
        "prod_replica": "s3://mybucket/db.sqlite3",
    },
}

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": BASE_DIR / "db.sqlite3",
    },
    **get_vfs_databases(),  # adds VFS replicas
}

Usage

User.objects.using("prod_replica").all()  # read-only, on-demand page fetch

VFS replicas are read-only. Only x86_64 and arm64 supported. Multiple storage backends supported (S3, GCS, Azure Blob).

License

MIT. The bundled Litestream binary uses the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_litestream-0.5.11.post3.tar.gz (10.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

django_litestream-0.5.11.post3-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.whl (37.7 MB view details)

Uploaded Python 3musllinux: musl 1.1+ x86-64

django_litestream-0.5.11.post3-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.whl (34.9 MB view details)

Uploaded Python 3musllinux: musl 1.1+ ARM64

django_litestream-0.5.11.post3-py3-none-macosx_11_0_arm64.whl (36.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

django_litestream-0.5.11.post3-py3-none-macosx_10_9_x86_64.whl (38.8 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

django_litestream-0.5.11.post3-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file django_litestream-0.5.11.post3.tar.gz.

File metadata

  • Download URL: django_litestream-0.5.11.post3.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_litestream-0.5.11.post3.tar.gz
Algorithm Hash digest
SHA256 5b9bf4f69c0b200c5e7490b20b40c26cc8209f020268f109af063b8e22d2fc7a
MD5 f4bf56e8c785b80cc8f2a4bc105f0ac3
BLAKE2b-256 575b0a00cdb952c175b6aad7868ddaeefdc945f4f96a566cada310362a9e537c

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_litestream-0.5.11.post3.tar.gz:

Publisher: publish.yml on Tobi-De/django-litestream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_litestream-0.5.11.post3-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for django_litestream-0.5.11.post3-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 a355cadae48320f11512dc95c0c97fa75c6ef094909089ff2db8ef86f0b52469
MD5 da9ae1cc56f5221d733851186a2175ec
BLAKE2b-256 bfb4b4703732cbb58da2510e8bfd482c4b2352c5732a5f18f877365d15970a7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_litestream-0.5.11.post3-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.whl:

Publisher: publish.yml on Tobi-De/django-litestream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_litestream-0.5.11.post3-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for django_litestream-0.5.11.post3-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 52a7d0c5069a1fd678dc4a5a67b79ee04f9d71226ae8e646f1e497a67bf0a9b7
MD5 8e52f5217538aa241119e67b9b658a2d
BLAKE2b-256 e81486bf5be1f9e5e1d6e31742beef741bcbd631364fdc8144e437336eb73ce7

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_litestream-0.5.11.post3-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.whl:

Publisher: publish.yml on Tobi-De/django-litestream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_litestream-0.5.11.post3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for django_litestream-0.5.11.post3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77b6adfb3f3c8827c18ba59d50df121d3505122e8e5db13f3b9bf031a1ea645a
MD5 d2ec02f36471332bb06ed6283b5e8196
BLAKE2b-256 7aaff5b2a9b40cafec9250b600543e81071fa661c9009c44926142313dab6cc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_litestream-0.5.11.post3-py3-none-macosx_11_0_arm64.whl:

Publisher: publish.yml on Tobi-De/django-litestream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_litestream-0.5.11.post3-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for django_litestream-0.5.11.post3-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 227005174190fd08839ba62122775b3ae535f902c0b53bbd4cd99552e5ff42fd
MD5 408e8f719be0c6fc07be363695031067
BLAKE2b-256 7db2d08164019e2a98eea534b177dad8dd8129f437daa1e093c13ef6c76ea5f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_litestream-0.5.11.post3-py3-none-macosx_10_9_x86_64.whl:

Publisher: publish.yml on Tobi-De/django-litestream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_litestream-0.5.11.post3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_litestream-0.5.11.post3-py3-none-any.whl
Algorithm Hash digest
SHA256 8e879868266cd7688f70d27f5097a53e5a90cadb085d17a5f2f422f28066e090
MD5 840268bd12299abc95cba12ac24fad0a
BLAKE2b-256 6bd7d46b129138daa6bafc01db3a857e1431a5cc9ea9231590a8c3789978ecc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_litestream-0.5.11.post3-py3-none-any.whl:

Publisher: publish.yml on Tobi-De/django-litestream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page