This release is a pre-release and may not be stable for production use.
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
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)
| File | Size | Uploaded | |
|---|---|---|---|
| datasette_examples-0.1a0.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|