This release is a pre-release and may not be stable for production use.
datasette-litestream
A Datasette <-> Litestream plugin.
Installation
The plugin requires a recent alpha version of Datasette 1.0:
pip install 'datasette>=1.0a20'
Then install this plugin in the same environment as Datasette:
datasette install datasette-litestream
Usage
Replicate a single database to S3
To replicate my_database.db to S3, use the following configuration in your metadata.yaml file:
databases:
my_database:
plugins:
datasette-litestream:
replicas:
- url: s3://my-bucket/my_database
Then make sure you export LITESTREAM_ACCESS_KEY_ID and LITESTREAM_SECRET_ACCESS_KEY with your S3 credentials (or AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY), then run with:
datasette my_database.db -m metadata.yaml
Replicate all databases
If you have multiple attached databases in Datasette and want to replicate all of them, the top-level all-replicate key can be used.
plugins:
datasette-litestream:
all-replicate:
- s3://my-bucket/$DB_NAME
When all-replicate is used, a new replica URL is generated for each attached database. In this case, if you had a database named parking_tickets and another named city_budget, then datasette-litestream will replicate them to s3://my-bucket/parking_tickets and s3://my-bucket/city_budget.
This is done with "variables" that datasette-litestream replaces in the all-replicate URL. The supported variables are:
$DB_NAME: The name of the Datasette database to replicate.$DB_DIRECTORY: The full parent directory that the SQLite database resides.$PWD: The current working directory of the Datasette process.
Config
Some configuration in the metadata.yaml will be used to auto-generate the litestream.yml file under the hood. You can use this to customize the Litestream replication process.
Top-level
The following are valid keys that are allowed when specifying top-level plugin configuration:
all-replicate: A template replica URL used to replicate all attached Datasette databases, see above for details.metrics-addr: Defines theaddr:Litestream option, which will expose a Prometheus endpoint at the given URL. Use with caution on public Datasette instances! When defined, the metrics info will appear on thedatasette-litestreamstatus page.access-key-id: An alternate way to provide a S3 access key (though theLITESTREAM_ACCESS_KEY_IDenvironment variable is preferred).secret-access-key: An alternate way to provide a S3 secret key (though theLITESTREAM_SECRET_ACCESS_KEYenvironment variable is preferred).session-token: Optional AWS session token for temporary credentials (e.g., when using AWS STS).credentials-file: Path to a JSON file containing credentials (see Dynamic Credentials below).credentials-command: A CLI command to execute that returns JSON credentials (see Dynamic Credentials below).credentials-refresh-interval: How often (in seconds) to check for credential changes. Required when usingcredentials-fileorcredentials-command.
None of these keys are required.
Example:
plugins:
datasette-litestream:
all-replicate:
- XXX
- YYY
metrics-addr: :5001
access-key-id: $YOUR_KEY
secret-access-key: $YOUR_SECRET
Dynamic Credentials
For environments where credentials rotate or are fetched dynamically (e.g., from a secrets manager), you can configure datasette-litestream to read credentials from a file or execute a command, and periodically check for changes.
Important: You cannot specify both credentials-file and credentials-command - use one or the other.
Reading credentials from a file
Create a JSON file with your credentials:
{
"access-key-id": "AKIAIOSFODNN7EXAMPLE",
"secret-access-key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"session-token": "optional-session-token-for-temporary-credentials"
}
The session-token field is optional and only needed when using temporary AWS credentials (e.g., from AWS STS).
Then configure the plugin to read from this file:
plugins:
datasette-litestream:
credentials-file: /path/to/credentials.json
credentials-refresh-interval: 300 # Check every 5 minutes
Reading credentials from a command
You can also execute a CLI command that outputs JSON credentials. This is useful for integrating with secrets managers or credential vending services:
plugins:
datasette-litestream:
credentials-command: ./fetch_creds.sh --bucket my-bucket
credentials-refresh-interval: 300 # Check every 5 minutes
The command should output JSON to stdout in the same format:
{
"access-key-id": "AKIAIOSFODNN7EXAMPLE",
"secret-access-key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"session-token": "optional-session-token"
}
The session-token field is optional.
How credential refresh works
- On startup, credentials are loaded from the file or command
- Every
credentials-refresh-intervalseconds, the file is re-read or the command is re-executed - If the credentials have changed,
datasette-litestreamwill:- Stop the current litestream process
- Update the configuration with new credentials
- Start a new litestream process
- If loading credentials fails during a refresh check, the Datasette process will exit with an error
Database-level
The following options are allowed on database-level plugin configuration.
replicasmonitor-intervalcheckpoint-intervalmin-checkpoint-page-countmax-checkpoint-page-count
databases:
my_database:
plugins:
datasette-litestream:
replicas:
- s3://...
- file://...
monitor-interval: XXX
checkpoint-interval: XXX
min-checkpoint-page-count: XXX
max-checkpoint-page-count: XXX
See Litestream Database settings for more information.
Development
To set up this plugin locally, first checkout the code. Then run the tests using uv:
cd datasette-litestream
uv run pytest
To run Datasette with the plugin installed:
uv run datasette -c config.yaml
Metadata
Release files for datasette-litestream 0.2a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| datasette_litestream-0.2a0.tar.gz | 19.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| datasette_litestream-0.2a0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| datasette_litestream-0.2a0-py3-none-manylinux1_x86_64.whl | Python 3 | none | Linux glibc 2.5+ x86-64 | Details |
| datasette_litestream-0.2a0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| datasette_litestream-0.2a0-py3-none-macosx_10_6_x86_64.whl | Python 3 | none | macOS 10.6+ x86-64 | Details |
| datasette_litestream-0.2a0-py3-none-linux_armv7l.whl | Python 3 | none | linux armv7l | Details |
| datasette_litestream-0.2a0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.4 MB
Release files / datasette_litestream-0.2a0.tar.gz
| Download URL | datasette_litestream-0.2a0.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
216b201543f335499a2590a27873e23d7c242e72eb11045fcddf0c023f4b30e3
|
|
BLAKE2b-256 checksum How to use checksums |
24c06336f9ada45b490c7eaf3ca43d39867f18a525d749edbdac0888ff51dce7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / datasette_litestream-0.2a0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | datasette_litestream-0.2a0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 8.7 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
e9cd609898f437f3c430cad0c3496fbf9693d666c71048b9af0d40ed0393f5b7
|
|
BLAKE2b-256 checksum How to use checksums |
e40ae18893591ffbb6375729d9730577d09685500ab717ffdd5e94e9abb56335
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / datasette_litestream-0.2a0-py3-none-manylinux1_x86_64.whl
| Download URL | datasette_litestream-0.2a0-py3-none-manylinux1_x86_64.whl |
|---|---|
| Size | 9.6 MB |
| Tags | Linux glibc 2.5+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
f2c03877b522740341e0ae8cc8890147dc1c915060c84c158dbb573496c09aa3
|
|
BLAKE2b-256 checksum How to use checksums |
14e72b5932346cdb9bbeccad73418b37dda4bcc7fa510a45ca474f562ff59cae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / datasette_litestream-0.2a0-py3-none-macosx_11_0_arm64.whl
| Download URL | datasette_litestream-0.2a0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 9.2 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c5179a8a3f3e3e5b4453b7392c83b42b82f8cdee37233affbce295d726d9fffd
|
|
BLAKE2b-256 checksum How to use checksums |
b0432592b5a889357bb0c06dd579949b225fbc01955e051151d4f607033379e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / datasette_litestream-0.2a0-py3-none-macosx_10_6_x86_64.whl
| Download URL | datasette_litestream-0.2a0-py3-none-macosx_10_6_x86_64.whl |
|---|---|
| Size | 10.0 MB |
| Tags | Python 3 macOS 10.6+ x86-64 |
|
SHA-256 checksum How to use checksums |
9e9f0d24b3a49d4f7cf26efb4bd3b18c4db660d539f1a9468565c53dad4a3b46
|
|
BLAKE2b-256 checksum How to use checksums |
d6480714edc54dd1ce0e057ac8c777fdeef5e8a5ff739ab6dcd2d3ae03dc1873
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / datasette_litestream-0.2a0-py3-none-linux_armv7l.whl
| Download URL | datasette_litestream-0.2a0-py3-none-linux_armv7l.whl |
|---|---|
| Size | 8.9 MB |
| Tags | Python 3 linux armv7l |
|
SHA-256 checksum How to use checksums |
426dbc72adb88c21e5380399f77518c74122c4962bb4c7614b9f2018290f0d5b
|
|
BLAKE2b-256 checksum How to use checksums |
ac9e15a7c5242c6b3a48be4d657a9c574ae113d3ef8d083f7807d8554bb41c72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / datasette_litestream-0.2a0-py3-none-any.whl
| Download URL | datasette_litestream-0.2a0-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37fac0e67f733008041f0c8498a4aedff984f84eaee7c89d71c98aae39b48ce0
|
|
BLAKE2b-256 checksum How to use checksums |
41d6e302ca2e63898c1e7ae2bd9914ffc222cb118d39ad7987cfcad6307ddf68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|