SQL-like DSL for planning and executing scoped ChromaDB queries.
Project description
ChromaSQL
ChromaSQL is a lightweight SQL-flavoured DSL that makes it easy to express
queries against ChromaDB collections. It wraps ChromaDB’s collection.query
and collection.get APIs with a familiar syntax and provides utilities for
parsing, semantic planning, execution, and multi-collection fan-out.
Features
- Lark-based parser that converts SQL-like strings into typed AST nodes.
- Planner that translates the AST into validated
QueryPlanobjects ready for ChromaDB execution. - Thin executor that orchestrates vector and filter queries, applies ordering and pagination, and normalises result rows.
- Optional multi-collection helpers and adapters for routing queries across sharded datasets.
- Analysis helpers for extracting metadata-driven routing hints.
For a clause-by-clause walkthrough, see TUTORIAL.md. Additional usage notes
and examples live in EXAMPLES.md, while edge cases for OR-based routing are
documented in OR_ROUTING_EDGE_CASES.md.
Installation
pip install chromasql
Quickstart
from chromasql import parse, build_plan, execute_plan
query = parse(
"""
SELECT id, document
FROM products
USING EMBEDDING (TEXT 'mesh office chair')
TOPK 5;
"""
)
plan = build_plan(query)
result = execute_plan(plan, collection=my_chroma_collection, embed_fn=my_embed_fn)
for row in result.rows:
print(row["id"], row["document"])
Development
We publish chromasql from this monorepo. Use the helper scripts in
scripts/ to build wheels, upload to PyPI, or synchronise the public mirror.
See CONTRIBUTING.md for architectural background and testing guidelines.
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
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 chromasql-1.4.0.tar.gz.
File metadata
- Download URL: chromasql-1.4.0.tar.gz
- Upload date:
- Size: 35.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0109f9d3d0d2ed46faf10252f4f085034dec034d688830ed64a5c06f8e21b8f9
|
|
| MD5 |
ece81c35ac0914aa443a8c8282436e25
|
|
| BLAKE2b-256 |
b418b03059fb750fae9461b9201bd9dd897779ec03fe5dfec8c0287d069f52e1
|
File details
Details for the file chromasql-1.4.0-py3-none-any.whl.
File metadata
- Download URL: chromasql-1.4.0-py3-none-any.whl
- Upload date:
- Size: 40.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c0beb485391eb11dc917fb3a427e6be49285e5104a40a07ea44545fa02354b3
|
|
| MD5 |
1218cf64fbf26e72c68320b7c22aa9c0
|
|
| BLAKE2b-256 |
3f6b3e3e48c1f36baab268fbac28432fa664c13a536fac7610fcdaf259535251
|