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.
  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), 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


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.tar.gz (7.6 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-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

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

Hashes for datasette_demo_dbs-0.1.tar.gz
Algorithm Hash digest
SHA256 9b5cbd7007a2567aa8fc263f97f8e09db66511d291c3a9933e9f1af500f50b21
MD5 1c287e5c5930953a149fc3ce19a744bc
BLAKE2b-256 4b4feb0e3f8703c7741c433ca45bfd24aa8129138da0648145322fccdcd0bbf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_demo_dbs-0.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-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_demo_dbs-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d004197518236130ad3eb2f22a8beb46b3f6ff36c89442b9520ff30e40ef6f5
MD5 bca1be695230a7fdf4cfd5fd544eba19
BLAKE2b-256 5096eca112a9c041af903ba148a6fd52c731046ec106d3bc14eaad0d7c101952

See more details on using hashes here.

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

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