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.8.0.tar.gz (36.6 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.8.0-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for chromasql-1.8.0.tar.gz
Algorithm Hash digest
SHA256 880f351db0dc94de4f5cc24a43e16be721275d4ac8e2c4405b95fb594a318b1e
MD5 8f4858b2aa3a6a2b88930fc7c3dd5692
BLAKE2b-256 143471c62472ec8355ba73b3dc7465de627d10288bd7484296d69b968dd3e911

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for chromasql-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1ddab0caf15fad4a1f69e626dab7458bfadad2154ef697ec59dd9ffd02dcd72
MD5 3d33b6bf9cfac7b763b086aec0c5c3ed
BLAKE2b-256 7c214c65fe2df7b2a3a39f299792d91dcab6d00a2b73e45ee196709d9da510b1

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