Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

datasette-examples

PyPI Changelog Tests License

Load example SQL scripts into Datasette on startup

Installation

Install this plugin in the same environment as Datasette.

pip install datasette-examples

Usage

This plugin is configured using metadata.yaml (or metadata.json or datasette.yml in Datasette 1.0).

Loading example SQL

Add a block like this that specifies the example SQL scripts you would like to load:

plugins:
  datasette-examples:
    startup:
      examples:
      - url: https://example.com/path/to/example1.sql
        if_not_table: table_name_1
      - url: https://example.com/path/to/example2.sql
        if_not_table: table_name_2

When Datasette starts running, it will:

  1. Check if the specified table (if_not_table) exists in the examples.db database
  2. If the table doesn't exist, it will download the SQL file from the provided URL
  3. Execute the SQL against examples.db

The if_not_table should be set to a table that is created by the script, to prevent the script from executing more than once.

Development

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

cd datasette-examples
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Release files for datasette-examples 0.1a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datasette-examples 0.1a0
File Size Uploaded
datasette_examples-0.1a0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datasette-examples 0.1a0
File Interpreter ABI Platform
datasette_examples-0.1a0-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / datasette_examples-0.1a0.tar.gz

Download URL datasette_examples-0.1a0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
74f3528672675f36be8e016e21d1055912d52f3b9540365d2bd613a79cb06954
BLAKE2b-256 checksum
How to use checksums
2b02682a2134b351a0991561e620325a69b969679db32c0eb8365eaf8c306702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / datasette_examples-0.1a0-py3-none-any.whl

Download URL datasette_examples-0.1a0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39f0a364a7aceec29c44daf4d06908ae45ab66d857676bfcfa013ac2e0625abb
BLAKE2b-256 checksum
How to use checksums
a047090e7d4a2dc89407ea47b7ff79b3c073c0c76464a7dfc168ef8f0919564f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1a0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page