Skip to main content

Shillelagh adapter for querying Grist Documents.

Project description

shillelagh-gristapi

Shillelagh adapter for querying Grist Documents.

Command line usage

Configuration in ~/.config/shillelagh/shillelagh.yaml:

gristapi:
  api_key: <replace-with-your-key>
  server: <replace-with-your-server>
  org_id: <replace-with-your-org-id>
  • find your api_key in your profile settings,
  • set server to your server url, e.g. https://templates.getgrist.com,
  • find your org_id with the orgs endpoint, e.g. curl -H "Authorization: Bearer <replace-with-your-apy-key> "<replace-with-your-server>/api/orgs/" | jq '.[]|.id'.
# 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/tables/operation/listTables
SELECT * FROM 'grist://<replace-with-a-doc-id>/<replace-with-a-table-id>';

Python usage

import os

from shillelagh.backends.apsw.db import connect

connection = connect(
    ":memory:",
    adapter_kwargs={
        "gristapi": {
            "api_key": os.environ["GRIST_API_KEY"],
            "server": os.environ["GRIST_SERVER"],
            "org_id": os.environ["GRIST_ORG_ID"],
        }
    },
)
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/tables/operation/listTables
query = "SELECT * FROM 'grist://<replace-with-a-doc-id>/<replace-with-a-table-id>';"
cursor.execute(query).fetchall()

Superset usage

To make the shillelagh-gristapi plugin available, add the following to your requirements-local.txt file:

shillelagh
shillelagh-gristapi

SqlAlchemy URI

shillelagh+safe://

Engine parameters

{
  "connect_args":
    {
      "adapters":
        ["gristapi"],
      "adapter_kwargs":
        {
          "gristapi":{
            "api_key": "<REPLACE_WITH_YOUR_API_KEY>",
            "server": "<REPLACE_WITH_YOUR_SERVER_URL>",
            "org_id": "<REPLACE_WITH_YOUR_ORD_ID>"
          }
        }
    }
}
SqlAlchemy URI Engine parameters
screenshot base screenshot parametres
SQL Lab
screenshot sql lab

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shillelagh_gristapi-0.0.9.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shillelagh_gristapi-0.0.9-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file shillelagh_gristapi-0.0.9.tar.gz.

File metadata

  • Download URL: shillelagh_gristapi-0.0.9.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for shillelagh_gristapi-0.0.9.tar.gz
Algorithm Hash digest
SHA256 fa20b7492f0fe85c202346b2d7e89faa84dd36ba2ff71f1eb9a3823a80487031
MD5 f2416cc9b8a08d7e242dc1ed834383ba
BLAKE2b-256 30d2a9a93873095d9fea3e0d405f6844e88cea945e6a9954eb6b1de651b6fa52

See more details on using hashes here.

File details

Details for the file shillelagh_gristapi-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for shillelagh_gristapi-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d73b5e5c184e36bd7251cc8226413e9bf04759eed319a351fabeefcbba0b2f38
MD5 94006ecdd08349f2e11b3cc46c8820f6
BLAKE2b-256 6ff3cb2de34ce7a865000d6a7f110deee624eef9b9931a0e1a27137cad4d230a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page