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.7.0.tar.gz (36.4 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.7.0-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for chromasql-1.7.0.tar.gz
Algorithm Hash digest
SHA256 7c29700d977b2cb039426370a7d7d6c484cf5393dd81c5dc6528d55f167d83dd
MD5 5338772879ffa22823e1b1a5b27757a7
BLAKE2b-256 d8cff9139ed3404c529b4714a46474df3cef46b56d2be481a1e0d99cebe93ce1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chromasql-1.7.0-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.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43b8e453daffbeb9d1d111e7185f40c77899af42335a319f4a698672387f16c0
MD5 71b4074193700475a33d1cda79c1d244
BLAKE2b-256 7c442d833d407b1e8fc2e40e056e5244b7c7ee90d721a91b386723cecbb1b976

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