Metadata-Version: 2.4
Name: shillelagh-gristapi
Version: 0.2.1
Summary: Shillelagh adapter to query Grist documents and tables via SQL.
Author: Quentin Leroy
License: MIT License
        
        Copyright (c) 2025 Quentin LEROY
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/qleroy/shillelagh-gristapi
Project-URL: Issues, https://github.com/qleroy/shillelagh-gristapi/issues
Keywords: shillelagh,grist,sql,adapter,superset
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: shillelagh>=1.4.0
Requires-Dist: requests<3,>=2.32.0
Provides-Extra: dev
Requires-Dist: pytest>=8.2; extra == "dev"
Requires-Dist: pytest-cov>=5.0; extra == "dev"
Requires-Dist: responses>=0.25.0; extra == "dev"
Requires-Dist: ruff>=0.6.9; extra == "dev"
Requires-Dist: mypy>=1.11.2; extra == "dev"
Requires-Dist: types-requests; extra == "dev"
Requires-Dist: build; extra == "dev"
Dynamic: license-file

# shillelagh-gristapi

A [Shillelagh](https://github.com/betodealmeida/shillelagh) adapter that exposes the [Grist REST API](https://support.getgrist.com/api/) as SQL-queryable virtual tables via SQLite/SQLAlchemy.

## Features

- Query Grist documents, tables, and records with SQL
- Filter pushdown for `=` and `IN` conditions; server-side `ORDER BY` and `LIMIT`
- Discovery queries: list organizations, workspaces, documents, and tables via `grist://` URIs
- Column metadata introspection via `grist://<doc_id>/<table_id>/__columns__`
- Built-in TTL caching (SQLite or in-memory) to reduce API calls
- Enforces Grist access rules — your API key permissions apply automatically
- Works with Apache Superset, the `shillelagh` CLI, and any SQLAlchemy-compatible tool

## Installation

```bash
pip install shillelagh-gristapi
```

For the interactive CLI:

```bash
pip install 'shillelagh[console]'
```

For source installation, see [docs/getting-started.md](docs/getting-started.md).

## Quickstart

```python
from shillelagh.backends.apsw.db import connect
import os

conn = connect(
    ":memory:",
    adapter_kwargs={"gristapi": {"grist_cfg": {
        "server": os.environ["GRIST_SERVER"],
        "org_id": int(os.environ["GRIST_ORG_ID"]),
        "api_key": os.environ["GRIST_API_KEY"],
    }}},
)
cursor = conn.cursor()
rows = cursor.execute('SELECT * FROM "grist://<DOC_ID>/<TABLE_ID>" LIMIT 10').fetchall()
```

## Documentation

| Document | Description |
|---|---|
| [docs/getting-started.md](docs/getting-started.md) | Prerequisites, install, step-by-step first queries |
| [docs/uri-reference.md](docs/uri-reference.md) | All `grist://` URI patterns and their column schemas |
| [docs/configuration.md](docs/configuration.md) | CLI, Python, and Superset configuration reference |
| [docs/type-mapping.md](docs/type-mapping.md) | Grist column types to SQL/Shillelagh field mapping |
| [docs/superset.md](docs/superset.md) | Apache Superset integration guide |
| [docs/limitations.md](docs/limitations.md) | Known restrictions and performance notes |

## License

MIT — see [LICENSE](LICENSE).
