Datasette plugin for scanning for SQLite files
Project description
datasette-scan
Datasette plugin that scans directories for SQLite database files and serves them.
Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-scan
Usage
Scan the current directory for SQLite files and serve them:
datasette scan
Scan a specific directory:
datasette scan /path/to/directory
Scan multiple directories and include explicit database files:
datasette scan /data/projects /data/archives extra.db
Specify a port (or any other datasette serve option):
datasette scan -p 8001
All options accepted by datasette serve are also accepted by datasette scan -- these are introspected at runtime, so new options added to future versions of Datasette will be picked up automatically.
How it works
- Positional arguments that are directories are scanned recursively for SQLite files using the sqlite-scanner binary, which identifies SQLite files by their magic bytes rather than file extension.
- Positional arguments that are files are passed through directly as database files.
- If no positional arguments are given, the current directory (
.) is scanned. - Discovered files are then served as if you had run
datasette serve file1.db file2.db ....
Continuous scanning
Use --scan-interval to periodically re-scan directories for new SQLite files while the server is running. New databases will be added automatically.
datasette scan /data --scan-interval 5
This re-scans every 5 seconds. Any new SQLite files that appear in the scanned directories will be added to the running Datasette instance without a restart.
Corrupted and locked files
Since datasette scan discovers files automatically, it takes precautions against problematic databases:
- Corrupted files are skipped. Each discovered file is validated by running
SELECT * FROM sqlite_masterbefore it is served. Files that fail this check are skipped with a warning to stderr. - Locked files are handled safely. Databases locked by another process are opened in read-only mode instead of causing the server to fail. (The
--nolockoption fromdatasette serveis always enabled and not exposed as a separate flag.)
These protections apply to files discovered by scanning directories. Explicit file arguments are passed through to datasette serve without validation.
Examples
Scan the current directory and open in a browser:
datasette scan -o
Scan with CORS enabled on a custom port:
datasette scan /data --cors -p 9000
Use --get to test without starting a server:
datasette scan /data --get /.json
Development
To set up this plugin locally, first checkout the code. You can confirm it is available like this:
cd datasette-scan
# Confirm the plugin is visible
uv run datasette plugins
To run the tests:
uv run 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_scan-0.1.tar.gz.
File metadata
- Download URL: datasette_scan-0.1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29dc2b2cf138fc4d1c375102bc9bb04e1c7efbbd3a7d632fb9234b780823ddd2
|
|
| MD5 |
ae535ba83af6300dc5197485578ca0fb
|
|
| BLAKE2b-256 |
0eaac4d952158262b3c5619d95fedf4e4c370a2ff5725c250c494a2bdd92ab2e
|
Provenance
The following attestation bundles were made for datasette_scan-0.1.tar.gz:
Publisher:
publish.yml on simonw/datasette-scan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_scan-0.1.tar.gz -
Subject digest:
29dc2b2cf138fc4d1c375102bc9bb04e1c7efbbd3a7d632fb9234b780823ddd2 - Sigstore transparency entry: 909900479
- Sigstore integration time:
-
Permalink:
simonw/datasette-scan@a74a453ecdc0d37f73fd7d34612864ac8e5f960b -
Branch / Tag:
refs/tags/0.1 - Owner: https://github.com/simonw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a74a453ecdc0d37f73fd7d34612864ac8e5f960b -
Trigger Event:
release
-
Statement type:
File details
Details for the file datasette_scan-0.1-py3-none-any.whl.
File metadata
- Download URL: datasette_scan-0.1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a464557b479b3167f9d2013867d412aba3f3111f81afc03deb05ed023455bd4
|
|
| MD5 |
95a5609ab0be651780156579bd152aae
|
|
| BLAKE2b-256 |
f86b1f7b918c25fc6aeb8017f25a999c0f8fe059560a89dca21bc7d520fdf3bc
|
Provenance
The following attestation bundles were made for datasette_scan-0.1-py3-none-any.whl:
Publisher:
publish.yml on simonw/datasette-scan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_scan-0.1-py3-none-any.whl -
Subject digest:
5a464557b479b3167f9d2013867d412aba3f3111f81afc03deb05ed023455bd4 - Sigstore transparency entry: 909900482
- Sigstore integration time:
-
Permalink:
simonw/datasette-scan@a74a453ecdc0d37f73fd7d34612864ac8e5f960b -
Branch / Tag:
refs/tags/0.1 - Owner: https://github.com/simonw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a74a453ecdc0d37f73fd7d34612864ac8e5f960b -
Trigger Event:
release
-
Statement type: