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.0.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.0-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chromasql-1.5.0.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.0.tar.gz
Algorithm Hash digest
SHA256 2c2098b1099cb7f11179814a42eccfead96dc0713006d9a162d795e80b5de13a
MD5 73f4e1c7dfe59e75f193b3181de9db27
BLAKE2b-256 4bf66e720d2451a57425cda4469476a771703ae03146cc7a957799dd50669b31

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chromasql-1.5.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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f89980bbacce702c452010378f5d998a596d811685d7c7a338690fd5e4e4b024
MD5 b972b660c5a2ddd67a187bb1f304e2a1
BLAKE2b-256 5d9d9cf787d4e3f5cb6510d984bb6b453432e6947ca9300fa32e05bdfb63dc7f

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