Fetch missing demo DBs from URLs when Datasette first starts
Project description
datasette-demo-dbs
Fetch missing demo DBs from URLs when Datasette first starts
Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-demo-dbs
Configuration
Configure the plugin in your Datasette metadata (YAML or JSON). You specify:
path: directory on disk where downloaded .db files will be stored (defaults to current directory)dbs: a mapping of database name to the URL of the SQLite database file
Example metadata.yml:
plugins:
datasette-demo-dbs:
path: ./demo-dbs
dbs:
demo: https://example.com/path/to/demo.db
census: https://example.com/path/to/census.db
Equivalent metadata.json:
{
"plugins": {
"datasette-demo-dbs": {
"path": "./demo-dbs",
"dbs": {
"demo": "https://example.com/path/to/demo.db",
"census": "https://example.com/path/to/census.db"
}
}
}
}
How it works
On Datasette startup, for each entry in dbs:
- If
path/<name>.dbalready exists, it is left as-is. - If a marker file
path/<name>.deletedexists, the download is skipped. - Otherwise, the plugin downloads the content from the URL (following redirects), writes it to
path/<name>.db, and registers that database in Datasette under the given name.
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-demo-dbs
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
python -m pytest
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 Distribution
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 datasette_demo_dbs-0.1.tar.gz.
File metadata
- Download URL: datasette_demo_dbs-0.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b5cbd7007a2567aa8fc263f97f8e09db66511d291c3a9933e9f1af500f50b21
|
|
| MD5 |
1c287e5c5930953a149fc3ce19a744bc
|
|
| BLAKE2b-256 |
4b4feb0e3f8703c7741c433ca45bfd24aa8129138da0648145322fccdcd0bbf9
|
Provenance
The following attestation bundles were made for datasette_demo_dbs-0.1.tar.gz:
Publisher:
publish.yml on datasette/datasette-demo-dbs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_demo_dbs-0.1.tar.gz -
Subject digest:
9b5cbd7007a2567aa8fc263f97f8e09db66511d291c3a9933e9f1af500f50b21 - Sigstore transparency entry: 395218679
- Sigstore integration time:
-
Permalink:
datasette/datasette-demo-dbs@4f7e017add73cedd6bab86be56d4c57f91825f16 -
Branch / Tag:
refs/tags/0.1 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4f7e017add73cedd6bab86be56d4c57f91825f16 -
Trigger Event:
release
-
Statement type:
File details
Details for the file datasette_demo_dbs-0.1-py3-none-any.whl.
File metadata
- Download URL: datasette_demo_dbs-0.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d004197518236130ad3eb2f22a8beb46b3f6ff36c89442b9520ff30e40ef6f5
|
|
| MD5 |
bca1be695230a7fdf4cfd5fd544eba19
|
|
| BLAKE2b-256 |
5096eca112a9c041af903ba148a6fd52c731046ec106d3bc14eaad0d7c101952
|
Provenance
The following attestation bundles were made for datasette_demo_dbs-0.1-py3-none-any.whl:
Publisher:
publish.yml on datasette/datasette-demo-dbs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_demo_dbs-0.1-py3-none-any.whl -
Subject digest:
2d004197518236130ad3eb2f22a8beb46b3f6ff36c89442b9520ff30e40ef6f5 - Sigstore transparency entry: 395218694
- Sigstore integration time:
-
Permalink:
datasette/datasette-demo-dbs@4f7e017add73cedd6bab86be56d4c57f91825f16 -
Branch / Tag:
refs/tags/0.1 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4f7e017add73cedd6bab86be56d4c57f91825f16 -
Trigger Event:
release
-
Statement type: