Skip to main content

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 QueryPlan objects 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

chromasql-1.5.1.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

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

chromasql-1.5.1-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

File details

Details for the file chromasql-1.5.1.tar.gz.

File metadata

  • Download URL: chromasql-1.5.1.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for chromasql-1.5.1.tar.gz
Algorithm Hash digest
SHA256 ff6b42f6c2483f06dffbb739b381f1fd027e69916a63d49dc67b5ee02688cc07
MD5 ef20a01406ee46a59130b9ff44a1b2bc
BLAKE2b-256 93b65a6d6756c873a953e9070a9a1bfb84ece00fe8f8e9f96e768c47a3bcef32

See more details on using hashes here.

File details

Details for the file chromasql-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: chromasql-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 41.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for chromasql-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b867a81f246e4b4b361241c077b2b47bfb1099cefc16e24bbc6ad405407c29be
MD5 e5e5c4710c158940f613595909bb6a93
BLAKE2b-256 eda1469e613ff80ccc6a531c8baf36053bdc5a738490714d5ab0d970c0120b9e

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