Skip to main content

Fetch missing demo DBs from URLs when Datasette first starts

Project description

datasette-demo-dbs

PyPI Changelog Tests License

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:

  1. If path/<name>.db already exists, it is left as-is and loaded into Datasette.
  2. If a marker file path/<name>.deleted exists, the download is skipped.
  3. Otherwise, the plugin downloads the content from the URL (following redirects), streams 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


Download files

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

Source Distribution

datasette_demo_dbs-0.1.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

datasette_demo_dbs-0.1.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file datasette_demo_dbs-0.1.1.tar.gz.

File metadata

  • Download URL: datasette_demo_dbs-0.1.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for datasette_demo_dbs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 10696bd70b0209d033faf61089fe00c69e6a69e3b4cdb5a40991929dcba93b11
MD5 1f258381ab223ef2a3a5cace780a6d18
BLAKE2b-256 a3af2b012f6af95dc94f38fccdd22627549dc7e9c1cd02dec88700580fa2eb14

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_demo_dbs-0.1.1.tar.gz:

Publisher: publish.yml on datasette/datasette-demo-dbs

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

File details

Details for the file datasette_demo_dbs-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_demo_dbs-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fdc1d52f1c6356089719ac2eca604abcea5f5f56941ff77011759de8e81ec67
MD5 0e64f0f8e9105f91458fff43092829ff
BLAKE2b-256 64adb12ef75725f50f5a98b4019d07e019736c1432ca58268c784219900b371d

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_demo_dbs-0.1.1-py3-none-any.whl:

Publisher: publish.yml on datasette/datasette-demo-dbs

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