Load example SQL scripts into Datasette on startup
Project description
datasette-examples
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:
- Check if the specified table (
if_not_table) exists in theexamples.dbdatabase - If the table doesn't exist, it will download the SQL file from the provided URL
- 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datasette_examples-0.1a0.tar.gz.
File metadata
- Download URL: datasette_examples-0.1a0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74f3528672675f36be8e016e21d1055912d52f3b9540365d2bd613a79cb06954
|
|
| MD5 |
ee73ec736ab4c27469fdb62f61857b81
|
|
| BLAKE2b-256 |
2b02682a2134b351a0991561e620325a69b969679db32c0eb8365eaf8c306702
|
File details
Details for the file datasette_examples-0.1a0-py3-none-any.whl.
File metadata
- Download URL: datasette_examples-0.1a0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39f0a364a7aceec29c44daf4d06908ae45ab66d857676bfcfa013ac2e0625abb
|
|
| MD5 |
f7f37161178a44290ae79d5d1cce7b38
|
|
| BLAKE2b-256 |
a047090e7d4a2dc89407ea47b7ff79b3c073c0c76464a7dfc168ef8f0919564f
|