Skip to main content

API and UI for bulk loading data into Datasette from a URL

Project description

datasette-load

PyPI Changelog Tests License

API and UI for bulk loading data into Datasette from a URL

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-load

Configuration

This plugin does not require configuration - by default it downloads files to the system temp directory and swaps them into the current working directory once they have been verified as valid SQLite.

The plugin provides two optional settings to control which directories are used here:

plugins:
  datasette-load:
    staging_directory: /tmp
    database_directory: /home/location

staging_directory is used for the initial download. Files will be deleted from here if the download fails.

If the download succeeds (and the database integrity check passes) the file will be moved into the database_directory folder. This defaults to the directory in which the Datasette application was started if you do not otherwise configure it.

Usage

Users and API tokens with the datasette-load permission can visit /-/load where they can provide a URL to a SQLite database file and the name it should use within Datasette to trigger a download of that SQLite database.

You can assign that permission to the root user by starting Datasette like this:

datasette -s permissions.datasette-load.id root --root

Or with the following configuration in the datasette -c datasette.yaml file:

permissions:
  datasette-load:
    id: root

API tokens with that permission can use this API:

POST /-/load
{"url": "https://s3.amazonaws.com/til.simonwillison.net/tils.db", "name": "tils"}

This tells Datasette to download the SQLite database from the given URL and use it to create (or replace) the /tils database in the Datasette instance.

That API endpoint returns:

{
  "id": "1D2A2328-199E-4D4D-AF3B-967131ADB795",
  "url": "https://s3.amazonaws.com/til.simonwillison.net/tils.db",
  "name": "tils",
  "done": false,
  "error": null,
  "todo_bytes": 20250624,
  "done_bytes": 0,
  "status_url": "https://blah.datasette/-/load/status/1D2A2328-199E-4D4D-AF3B-967131ADB795"
}

The status_url can be polled for completion. It will return the same JSON format.

When the download has finished the API will return "done": true and either "error": null if it worked or "error": "error description" if something went wrong.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-load
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_load-0.1a1.tar.gz (13.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_load-0.1a1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file datasette_load-0.1a1.tar.gz.

File metadata

  • Download URL: datasette_load-0.1a1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for datasette_load-0.1a1.tar.gz
Algorithm Hash digest
SHA256 7594b9afa6d12e691efbea32611c560ccc5814c6980c67fddf3919ea0455eeb1
MD5 ae3782021b5fd4a129c03c400fe6ca26
BLAKE2b-256 e4b9c60bc34a1c3500f3052d9739e495e1d5c38c900cde14c27460fcff034e46

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_load-0.1a1.tar.gz:

Publisher: publish.yml on datasette/datasette-load

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_load-0.1a1-py3-none-any.whl.

File metadata

  • Download URL: datasette_load-0.1a1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for datasette_load-0.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 a318d68e43fb911042fb98a5bf9e9ed242d22b8cde1b6c29e34edad2f047a067
MD5 27916e9fa96689740ae1ad8e39f19f36
BLAKE2b-256 c54e07f3a100944aa8db6a89f4cdfc1b9f17249625320c1316b9851ed1dc3bb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_load-0.1a1-py3-none-any.whl:

Publisher: publish.yml on datasette/datasette-load

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