{"id":48555274,"url":"https://github.com/paradedb/sqlalchemy-paradedb","last_synced_at":"2026-04-16T17:08:03.538Z","repository":{"id":342438002,"uuid":"1161106675","full_name":"paradedb/sqlalchemy-paradedb","owner":"paradedb","description":"ParadeDB support for SQLAlchemy ORM","archived":false,"fork":false,"pushed_at":"2026-04-01T17:51:06.000Z","size":242,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-02T03:11:39.198Z","etag":null,"topics":["orm","paradedb","python","sqlalchemy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paradedb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["paradedb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2026-02-18T18:35:29.000Z","updated_at":"2026-04-01T17:51:10.000Z","dependencies_parsed_at":"2026-03-06T04:17:28.184Z","dependency_job_id":null,"html_url":"https://github.com/paradedb/sqlalchemy-paradedb","commit_stats":null,"previous_names":["paradedb/sqlalchemy-paradedb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/paradedb/sqlalchemy-paradedb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradedb%2Fsqlalchemy-paradedb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradedb%2Fsqlalchemy-paradedb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradedb%2Fsqlalchemy-paradedb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradedb%2Fsqlalchemy-paradedb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paradedb","download_url":"https://codeload.github.com/paradedb/sqlalchemy-paradedb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradedb%2Fsqlalchemy-paradedb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31551698,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["orm","paradedb","python","sqlalchemy"],"created_at":"2026-04-08T10:30:36.635Z","updated_at":"2026-04-08T10:30:37.714Z","avatar_url":"https://github.com/paradedb.png","language":"Python","funding_links":["https://github.com/sponsors/paradedb"],"categories":[],"sub_categories":[],"readme":"\u003c!-- ParadeDB: Postgres for Search and Analytics --\u003e\n\u003ch1 align=\"center\"\u003e\n  \u003ca href=\"https://paradedb.com\"\u003e\u003cimg src=\"https://github.com/paradedb/paradedb/raw/main/docs/logo/readme.svg\" alt=\"ParadeDB\"\u003e\u003c/a\u003e\n\u003cbr\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eSimple, Elastic-quality search for Postgres\u003c/b\u003e\u003cbr/\u003e\n\u003c/p\u003e\n\n\u003ch3 align=\"center\"\u003e\n  \u003ca href=\"https://paradedb.com\"\u003eWebsite\u003c/a\u003e \u0026bull;\n  \u003ca href=\"https://docs.paradedb.com\"\u003eDocs\u003c/a\u003e \u0026bull;\n  \u003ca href=\"https://paradedb.com/slack/\"\u003eCommunity\u003c/a\u003e \u0026bull;\n  \u003ca href=\"https://paradedb.com/blog/\"\u003eBlog\u003c/a\u003e \u0026bull;\n  \u003ca href=\"https://docs.paradedb.com/changelog/\"\u003eChangelog\u003c/a\u003e\n\u003c/h3\u003e\n\n---\n\n# sqlalchemy-paradedb\n\n[![PyPI](https://img.shields.io/pypi/v/sqlalchemy-paradedb)](https://pypi.org/project/sqlalchemy-paradedb/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/sqlalchemy-paradedb)](https://pypi.org/project/sqlalchemy-paradedb/)\n[![Downloads](https://img.shields.io/pypi/dm/sqlalchemy-paradedb)](https://pypi.org/project/sqlalchemy-paradedb/)\n[![Codecov](https://codecov.io/gh/paradedb/sqlalchemy-paradedb/graph/badge.svg)](https://codecov.io/gh/paradedb/sqlalchemy-paradedb)\n[![License](https://img.shields.io/github/license/paradedb/sqlalchemy-paradedb?color=blue)](https://github.com/paradedb/sqlalchemy-paradedb?tab=MIT-1-ov-file#readme)\n[![Slack URL](https://img.shields.io/badge/Join%20Slack-purple?logo=slack\u0026link=https%3A%2F%2Fparadedb.com%2Fslack)](https://paradedb.com/slack)\n[![X URL](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2Fparadedb\u0026label=Follow%20%40paradedb)](https://x.com/paradedb)\n\n[ParadeDB](https://paradedb.com) integration for SQLAlchemy: typed helpers for BM25 indexes, search predicates, scoring, snippets, facets, and migration ergonomics.\n\n## Requirements \u0026 Compatibility\n\n| Component  | Supported                     |\n| ---------- | ----------------------------- |\n| Python     | 3.10+                         |\n| SQLAlchemy | 2.0.32+                       |\n| ParadeDB   | 0.22.0+                       |\n| PostgreSQL | 15+ (with ParadeDB extension) |\n\n## Installation\n\n```bash\nuv add sqlalchemy-paradedb\n```\n\nFor local development:\n\n```bash\nuv sync --extra test --extra dev\n```\n\n## Quick Start\n\n### Prerequisites\n\nInstall `pg_search` in your Postgres database and connect SQLAlchemy to that database.\n\n### Create a BM25 Index\n\n```python\nfrom sqlalchemy import Index\nfrom paradedb.sqlalchemy import indexing\n\nproducts_bm25_idx = Index(\n    \"products_bm25_idx\",\n    indexing.BM25Field(Product.id),\n    indexing.BM25Field(\n        Product.description,\n        tokenizer=indexing.tokenize.unicode(lowercase=True),\n    ),\n    indexing.BM25Field(\n        Product.category,\n        tokenizer=indexing.tokenize.literal(),\n    ),\n    postgresql_using=\"bm25\",\n    postgresql_with={\"key_field\": \"id\"},\n)\n```\n\nFor JSON columns named `metadata`, use `metadata_` as the ORM attribute name.\n\n### Query with ParadeDB Predicates\n\n```python\nfrom sqlalchemy import select\nfrom sqlalchemy.orm import Session\nfrom paradedb.sqlalchemy import pdb, search\n\nstmt = (\n    select(Product.id, Product.description)\n    .where(search.match_any(Product.description, \"running\", \"shoes\"))\n    .order_by(pdb.score(Product.id).desc())\n    .limit(10)\n)\n\nwith Session(engine) as session:\n    rows = session.execute(stmt).all()\n```\n\n### Rows + Facets in a Single Query\n\n```python\nfrom sqlalchemy import select\nfrom sqlalchemy.orm import Session\nfrom paradedb.sqlalchemy import facets, search\n\nbase = (\n    select(Product.id, Product.description)\n    .where(search.match_all(Product.description, \"running\"))\n    .order_by(Product.id)\n    .limit(10)\n)\n\nstmt = facets.with_rows(\n    base,\n    agg=facets.multi(\n        facets.value_count(field=\"id\"),\n        facets.terms(field=\"category\", size=10),\n    ),\n    key_field=Product.id,\n)\n\nwith Session(engine) as session:\n    rows = session.execute(stmt).all()\n    facet_payload = facets.extract(rows)\n```\n\n## Search Patterns\n\n### Fuzzy Matching\n\n```python\nfrom paradedb.sqlalchemy import search\n\nsearch.term(Product.description, \"shose\", distance=1)\nsearch.match_any(Product.description, \"wirless\", distance=1, prefix=True)\nsearch.term(Product.description, \"rnnuing\", distance=1, transpose_cost_one=True)\n```\n\nUse fuzzy options on `term`, `match_any`, or `match_all`; there is no separate `search.fuzzy(...)` helper.\n\n### Phrase Prefix and More-Like-This\n\n```python\nfrom paradedb.sqlalchemy import search\n\nsearch.phrase_prefix(Product.description, [\"running\", \"sh\"])\nsearch.more_like_this(Product.id, document_id=1, fields=[\"description\"])\n```\n\n### Proximity Composition\n\n```python\nfrom sqlalchemy import select\nfrom paradedb.sqlalchemy import search\n\nprox = search.prox_array(\"running\").within(1, search.prox_regex(\"sho.*\"), ordered=True)\nstmt = select(Product.id).where(search.proximity(Product.description, prox))\n```\n\n## Indexing and Tokenizers\n\nTokenizer config can be expressed as a structured mapping:\n\n```python\nfrom sqlalchemy import Index\nfrom paradedb.sqlalchemy import indexing\n\nproducts_bm25_idx = Index(\n    \"products_bm25_idx\",\n    indexing.BM25Field(Product.id),\n    indexing.BM25Field(\n        Product.description,\n        tokenizer=indexing.tokenize.from_config(\n            {\n                \"tokenizer\": \"simple\",\n                \"filters\": [\"lowercase\", \"stemmer\"],\n                \"stemmer\": \"english\",\n                \"alias\": \"description_simple\",\n            }\n        ),\n    ),\n    indexing.BM25Field(\n        Product.description,\n        tokenizer=indexing.tokenize.from_config(\n            {\n                \"tokenizer\": \"ngram\",\n                \"args\": [3, 8],\n                \"named_args\": {\"prefix_only\": True},\n                \"alias\": \"description_ngram\",\n            }\n        ),\n    ),\n    postgresql_using=\"bm25\",\n    postgresql_with={\"key_field\": \"id\"},\n)\n```\n\nValidate that a field is indexed with the expected tokenizer:\n\n```python\nfrom paradedb.sqlalchemy import indexing\n\nindexing.assert_indexed(engine, Product.category, tokenizer=\"literal\")\n```\n\nInspect BM25 metadata for a mapped table:\n\n```python\nfrom paradedb.sqlalchemy import indexing\n\nmeta = indexing.describe(engine, Product.__table__)\n```\n\n## Alembic Operations\n\nImport once in migration environment startup so Alembic registers ParadeDB operations:\n\n```python\nimport paradedb.sqlalchemy.alembic  # noqa: F401\n```\n\nUse custom operations in migrations:\n\n```python\nop.create_bm25_index(\n    \"products_bm25_idx\",\n    \"products\",\n    [\"id\", \"description\"],\n    key_field=\"id\",\n    table_schema=\"public\",\n)\nop.reindex_bm25(\"products_bm25_idx\", concurrently=True, schema=\"public\")\nop.drop_bm25_index(\"products_bm25_idx\", if_exists=True, schema=\"public\")\n```\n\n`op.reindex_bm25(..., concurrently=True)` must run outside a transaction (autocommit block).\n\n## Diagnostics Helpers\n\n`paradedb.sqlalchemy.diagnostics` exposes wrapper functions for ParadeDB diagnostics:\n\n```python\nfrom paradedb.sqlalchemy import diagnostics\n\nindexes = diagnostics.paradedb_indexes(engine)\nsegments = diagnostics.paradedb_index_segments(engine, \"products_bm25_idx\")\ncheck = diagnostics.paradedb_verify_index(engine, \"products_bm25_idx\", sample_rate=0.1)\nall_checks = diagnostics.paradedb_verify_all_indexes(engine, schema_pattern=\"public\")\n```\n\n## Common Errors\n\n### `with_rows requires ORDER BY`\n\n```python\nfrom sqlalchemy import select\nfrom paradedb.sqlalchemy import facets\n\n# Missing order_by(...)\nbase = select(Product.id).limit(10)\nfacets.with_rows(base, agg=facets.value_count(field=\"id\"), key_field=Product.id)\n```\n\n### `with_rows requires LIMIT`\n\n```python\nfrom sqlalchemy import select\nfrom paradedb.sqlalchemy import facets\n\n# Missing limit(...)\nbase = select(Product.id).order_by(Product.id)\nfacets.with_rows(base, agg=facets.value_count(field=\"id\"), key_field=Product.id)\n```\n\n### `with_rows requires a ParadeDB predicate`\n\n```python\nfrom sqlalchemy import select\nfrom paradedb.sqlalchemy import facets\n\n# ensure_predicate=False disables automatic search.all(...) injection\nfacets.with_rows(\n    select(Product.id).order_by(Product.id).limit(10),\n    agg=facets.value_count(field=\"id\"),\n    key_field=Product.id,\n    ensure_predicate=False,\n)\n```\n\n### `tokenizer config requires 'tokenizer'`\n\n```python\nfrom paradedb.sqlalchemy import indexing\n\nindexing.tokenize.from_config({\"filters\": [\"lowercase\"]})\n```\n\n## Examples\n\n- [Quick Start](examples/quickstart/quickstart.py)\n- [Faceted Search](examples/faceted_search/faceted_search.py)\n- [Autocomplete](examples/autocomplete/autocomplete.py)\n- [More Like This](examples/more_like_this/more_like_this.py)\n- [Hybrid Search (RRF)](examples/hybrid_rrf/hybrid_rrf.py)\n- [RAG](examples/rag/rag.py)\n\n## Documentation\n\n- **ParadeDB Official Docs**: \u003chttps://docs.paradedb.com\u003e\n- **ParadeDB Website**: \u003chttps://paradedb.com\u003e\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, running tests, linting, and the PR workflow.\n\n## Support\n\nIf you're missing a feature or have found a bug, please open a\n[GitHub Issue](https://github.com/paradedb/django-paradedb/issues/new/choose).\n\nTo get community support, you can:\n\n- Post a question in the [ParadeDB Slack Community](https://paradedb.com/slack)\n- Ask for help on our [GitHub Discussions](https://github.com/paradedb/paradedb/discussions)\n\nIf you need commercial support, please [contact the ParadeDB team](mailto:sales@paradedb.com).\n\n## License\n\nsqlalchemy-paradedb is licensed under the [MIT License](https://github.com/paradedb/sqlalchemy-paradedb?tab=MIT-1-ov-file#readme).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadedb%2Fsqlalchemy-paradedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparadedb%2Fsqlalchemy-paradedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadedb%2Fsqlalchemy-paradedb/lists"}