Shillelagh adapter to query Grist documents and tables via SQL.
Project description
shillelagh-gristapi
A Shillelagh adapter for the Grist REST API.
It lets you query Grist documents and tables with SQL via SQLite/SQLAlchemy,
ideal for BI tools like Apache Superset.
✨ Features
- Query Grist documents, tables, and records as if they were SQL tables
- Supports core SQL operations:
SELECTstatements on Grist tables- Filter pushdown for
=condition - Server-side sorting and
LIMIT
- Built-in discovery helpers:
grist://→ list all documentsgrist://<doc_id>→ list tables in a documentgrist://<doc_id>/<table_id>→ query rows in a table
- Flexible usage:
- CLI: via the
shillelaghshell orpython -m shillelagh_gristapi ... - Python: connect directly with the
connect()API - Superset: drop-in integration for dashboards
- CLI: via the
- Enforces Grist access rules:
Your Grist permissions carry over automatically.
If you can only see certain tables, columns, or rows in Grist,
you’ll see exactly the same restrictions through this adapter.
🚀 Installation
pip install shillelagh-gristapi
# CLI
pip install 'shillelagh[console]'
Or from source:
git clone https://github.com/qleroy/shillelagh-gristapi.git
cd shillelagh-gristapi
pip install -e .[dev]
⚙️ Configuration
You need a Grist API key.
- Fin doou
API_KEYin your profile settings. See Grist docs. - Find your
ORG_IDwith the orgs endpoint, e.g. curl -H "Authorization: Bearer "/api/orgs/" | jq '.[]|.id',
gristapi:
api_key: ${API_KEY}
org_id: ${ORG_ID}
server: ${SERVER} # e.g. https://docs.getgrist.com
🧑💻 Usage
🖥️ CLI
Default configuration in ~/.config/shillelagh/shillelagh.yaml:
$ shillelagh
# List document ids
# https://support.getgrist.com/api/#tag/workspaces/operation/listWorkspaces
SELECT * FROM 'grist://';
# List table ids
# https://support.getgrist.com/api/#tag/tables/operation/listTables
SELECT * FROM 'grist://<replace-with-a-doc-id>';
# Fetch records
# https://support.getgrist.com/api/#tag/records
SELECT * FROM 'grist://<replace-with-a-doc-id>/<replace-with-a-table-id>';
🐍 Python
import os
from shillelagh.backends.apsw.db import connect
connection = connect(
":memory:",
adapter_kwargs={
"gristapi": {
"api_key": os.environ["GRIST_API_KEY"],
"org_id": os.environ["GRIST_ORG_ID"],
"server": os.environ["GRIST_SERVER"],
}
},
)
cursor = connection.cursor()
# List document ids
# https://support.getgrist.com/api/#tag/workspaces/operation/listWorkspaces
query_docs = "SELECT * FROM 'grist://';"
cursor.execute(query_docs).fetchall()
# List table ids
# https://support.getgrist.com/api/#tag/tables/operation/listTables
query_tables = "SELECT * FROM 'grist://<replace-with-a-doc-id>';"
cursor.execute(query_tables).fetchall()
# Fetch records
# https://support.getgrist.com/api/#tag/records
query = "SELECT * FROM 'grist://<replace-with-a-doc-id>/<replace-with-a-table-id>';"
cursor.execute(query).fetchall()
📊 Apache Superset
- Install
shillelagh+ this adapter in your Superset image; - Add a Shillelagh database with URI
shillelagh+safe://
- Configure the engine parameters
{
"connect_args":
{
"adapters":
["gristapi"],
"adapter_kwargs":
{
"gristapi":{
"api_key": "<REPLACE_WITH_YOUR_API_KEY>",
"org_id": "<REPLACE_WITH_YOUR_ORD_ID>",
"server": "<REPLACE_WITH_YOUR_SERVER_URL>",
}
}
}
}
- Create a virtual dataset using a Grist URI, e.g.:
select * from 'grist://<doc-id>/<table-id>'
| SqlAlchemy URI | Engine parameters |
|---|---|
| SQL Lab |
|---|
📄 License
MIT — see (LICENSE)[/LICENSE].
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 shillelagh_gristapi-0.1.6.tar.gz.
File metadata
- Download URL: shillelagh_gristapi-0.1.6.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2454053e6987b19d9b892943f1226049eed73e115c1927f8cbeb860c0e08973f
|
|
| MD5 |
e94e31f7b38c8689aabf3135c29f13e8
|
|
| BLAKE2b-256 |
8382d5cbb19127909f51796f8ffed35fab3fc11ee12eecb8514c9541432bad6e
|
Provenance
The following attestation bundles were made for shillelagh_gristapi-0.1.6.tar.gz:
Publisher:
pypi.yml on qleroy/shillelagh-gristapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shillelagh_gristapi-0.1.6.tar.gz -
Subject digest:
2454053e6987b19d9b892943f1226049eed73e115c1927f8cbeb860c0e08973f - Sigstore transparency entry: 627208598
- Sigstore integration time:
-
Permalink:
qleroy/shillelagh-gristapi@e28519b35db9d7696b293225bf37823d6e88b06e -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/qleroy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@e28519b35db9d7696b293225bf37823d6e88b06e -
Trigger Event:
push
-
Statement type:
File details
Details for the file shillelagh_gristapi-0.1.6-py3-none-any.whl.
File metadata
- Download URL: shillelagh_gristapi-0.1.6-py3-none-any.whl
- Upload date:
- Size: 18.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 |
6e9905797786400cb455cc603e83763c69cc3efd35ba0ad468d0f2d10fbf9e29
|
|
| MD5 |
1f0eb3d17f012a84d4ea956ac3042fca
|
|
| BLAKE2b-256 |
83e9d51fac7b4c081864489fba90d529951994bf85e98f579d5efc4429d3f7ba
|
Provenance
The following attestation bundles were made for shillelagh_gristapi-0.1.6-py3-none-any.whl:
Publisher:
pypi.yml on qleroy/shillelagh-gristapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shillelagh_gristapi-0.1.6-py3-none-any.whl -
Subject digest:
6e9905797786400cb455cc603e83763c69cc3efd35ba0ad468d0f2d10fbf9e29 - Sigstore transparency entry: 627208641
- Sigstore integration time:
-
Permalink:
qleroy/shillelagh-gristapi@e28519b35db9d7696b293225bf37823d6e88b06e -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/qleroy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@e28519b35db9d7696b293225bf37823d6e88b06e -
Trigger Event:
push
-
Statement type: