Skip to main content

Periodically refresh Datasette metadata from a remote URL

Project description

datasette-remote-metadata

PyPI Changelog Tests License

Periodically refresh Datasette metadata from a remote URL

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-remote-metadata

The alpha version of this plugin requires Datasette 1.0a14 or higher.

Usage

Add the following to your datasette.yml:

plugins:
  datasette-remote-metadata:
    url: "https://example.com/remote-metadata.yml"

Then start Datasette like this:

datasette mydatabase.db -c datasette.yml

The plugin will fetch the specified metadata from that URL at startup and combine it with any existing metadata. You can use a URL to either a JSON file or a YAML file.

It will periodically refresh that metadata - by default every 30 seconds, unless you specify an alternative "ttl" value in the plugin configuration.

You can also use the datasette -s option to configure the plugin without a configuration file:

datasette \
  -s plugins.datasette-remote-metadata.url 'https://example.com/remote-metadata.yml' \
  -s plugins.datasette-remote-metadata.ttl 2 \
  mydatabase.db

Configuration

Available configuration options are as follows:

  • "url" - the URL to retrieve remote metadata from. Can link to a JSON or a YAML file.
  • "ttl" - integer value in secords: how frequently should the script check for fresh metadata. Defaults to 30 seconds.
  • "headers" - a dictionary of additional request headers to send.
  • "cachebust" - if true, a random ?0.29508 value will be added to the query string of the remote metadata to bust any intermediary caches.

This example datasette.yml configuration refreshes every 10 seconds, uses cache busting and sends an Authorization: Bearer xyz header with the request:

plugins:
  datasette-remote-metadata:
    url: "https://example.com/remote-metadata.yml"
    ttl: 10
    cachebust: true
    headers:
      Authorization: "Bearer xyz"

This example if you are using datasette.json for configuration:

{
  "plugins": {
    "datasette-remote-metadata": {
      "url": "https://example.com/remote-metadata.yml",
      "ttl": 10,
      "cachebust": true,
      "headers": {
        "Authorization": "Bearer xyz"
      }
    }
  }
}

Development

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

cd datasette-remote-metadata
python3 -mvenv venv
source venv/bin/activate

Or if you are using pipenv:

pipenv shell

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

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_remote_metadata-0.2a0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file datasette_remote_metadata-0.2a0.tar.gz.

File metadata

File hashes

Hashes for datasette_remote_metadata-0.2a0.tar.gz
Algorithm Hash digest
SHA256 688c93351c21dbd92fc3f8c9da3753c2f7fe0cc455d343159f18a10def03ae49
MD5 4cbd4154f1a5adbe168e2f2b058b486d
BLAKE2b-256 8a34da573846d3c0441195672caaeb0ebd3713e4a957d19103687bdb08baaf99

See more details on using hashes here.

File details

Details for the file datasette_remote_metadata-0.2a0-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_remote_metadata-0.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b17ad7e89e4c4563177838508a07e184f09d432530e3acd2510f685d9eda3c1
MD5 91c0d242859b47f33a114af7e91cdebe
BLAKE2b-256 32fc2a0ef4fbcac52a683103d567359ab520b4cff6fd7a8ae4e001245999c98a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page