datasette-peirce
Query any SQLite database using semantic coordinates instead of SQL — asking who, what, when, where, why, and how rather than writing column names and JOIN syntax.
It's as close as you can get to asking a question naturally without being probabilistic. No language model is guessing your intent. The query means exactly what it says, and the SQL it generates is always visible underneath.
WHO.artist_name = "Nina Simone"
WHAT.genre = "Jazz" AND WHEN.album_release_decade = "1960s"
WHO.attendee_name = "Alex" AND WHEN.session_date BETWEEN "2024-01-01" AND "2025-01-01"
WHAT.genre CONTAINS "Rock" OR WHAT.genre CONTAINS "Electronic"
WHEN.album_release_decade PREFIX "196"
How it works
You map your columns to dimensions once — in a browser, no JSON editing required. After that you query by meaning, not by column name.
open any SQLite database
↓
map columns in browser (WHO is a person, WHAT is a thing, WHEN is a date...)
↓
ask a question in Peirce
↓
see the SQL it generated
↓
hand off to Datasette's native view with filters already applied
The mapping step is the valuable part. Once your columns have stable semantic names, queries survive schema changes. Rename a column — update one line in the mapping, every query still works.
Install
pip install datasette-peirce
On Windows, use python -m pip if pip alone isn't recognised:
python -m pip install datasette-peirce
Quick start with the sample database
python make_sample_db.py
datasette data.db
On Windows:
python -m datasette data.db
Then open your browser and go to:
http://127.0.0.1:8001/-/peirce-query
If no mapping exists for your database yet, the plugin redirects you to the setup page automatically. Try a query:
WHO.attendee = "Smith"
You should see matching rows and the SQL it generated underneath. Press Ctrl+C to stop the server.
Using your own CSV
setup_datasette.py converts a CSV to a SQLite database and walks you through the column mapping interactively — no JSON editing:
python setup_datasette.py mydata.csv
It will read your CSV, show sample values for each column, suggest a dimension, and ask you to confirm or change it. When done it saves mydata.db and mydata.lens.json and prints three example queries from your actual data.
Then:
datasette mydata.db
You don't have to map every column — just the ones you want to query.
Query syntax
| Syntax | Example |
|---|---|
| Equality | WHO.name = "Smith" |
| Inequality | WHO.name != "Smith" |
| Substring | WHAT.title CONTAINS "garden" |
| Prefix | WHEN.decade PREFIX "196" |
| Range | WHEN.year BETWEEN "1960" AND "1980" |
| AND | WHO.name = "Smith" AND WHAT.genre = "Jazz" |
| OR | WHO.name = "Smith" OR WHO.name = "Jones" |
Available coordinates for your data are shown at the bottom of every query page.
Browser-based setup
Navigate to /-/peirce-query/setup to map your columns to dimensions in the browser. The plugin reads your schema, shows sample values, and suggests dimensions based on column names. You can also reach it via the "Edit mapping" link on any query page.
The six dimensions:
| Dimension | Means | Examples |
|---|---|---|
| WHO | a person or organisation | author, artist, attendee |
| WHAT | a thing, topic, or type | title, genre, ingredient |
| WHEN | a date, time, or year | published, session_date, decade |
| WHERE | a place or location | city, venue, country |
| WHY | a reason or classification | occasion, purpose, status |
| HOW | a method, format, or quantity | style, method, format |
The lens file
The mapping is saved as a .lens.json file next to your database. It's plain JSON and compatible with the broader snf-peirce ecosystem.
{
"lens_id": "my_data_v1",
"default_table": "my_table",
"mappings": [
{ "dimension": "WHO", "semantic_key": "author", "column": "author_name" },
{ "dimension": "WHAT", "semantic_key": "title", "column": "book_title" },
{ "dimension": "WHEN", "semantic_key": "year", "column": "pub_year" }
]
}
What this is not
This plugin is predicate pushdown into SQLite via a semantic facade. SQLite still does all the execution. It is not full SNF substrate routing — that's Reckoner.
Think of this as the lightweight entry point. If you find the model useful and want more — multiple sources, versioning, a full query workbench — that's what Reckoner is for.
Roadmap
- v0.1 (this): browser setup, Peirce query interface, SQL visible underneath, handoff to Datasette native view
- v0.2:
NOToperator, multi-table support - v0.3: DuckDB substrate support
Part of the peirce-lang ecosystem.
Metadata
Release files for datasette-peirce 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| datasette_peirce-0.1.0.tar.gz | 19.1 kB | Without provenance | Details for datasette_peirce-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datasette_peirce-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for datasette_peirce-0.1.0-py3-none-any.whl |
Total release size: 35.9 kB
Release files / datasette_peirce-0.1.0.tar.gz
| Download URL | datasette_peirce-0.1.0.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ff51d9fc9f5257b09e7d33add4617efaa57b3b0cc87e8cd41961dbfc0eb8d15
|
|
BLAKE2b-256 checksum How to use checksums |
7054fb6435e125c2579909837cba4e6c9d43b836517ba6047096cef2e44360cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Release files / datasette_peirce-0.1.0-py3-none-any.whl
| Download URL | datasette_peirce-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8278843f04f526690377a1605e0c9e983df05039389ac0579860ef3cef11cd8d
|
|
BLAKE2b-256 checksum How to use checksums |
345eaf4dba633cf7c6ab9be65ba9e9e8ccd124e6e83e570fd918f14365f4d50e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Security for datasette-peirce 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.