--- id: elasticsearch-dbapi version: "0.2.13" license: Apache License, Version 2.0 license_treatment: permissive maintenance: active --- # elasticsearch-dbapi — A DBAPI and SQLAlchemy dialect for Elasticsearch License: permissive · Maintenance: active · Downloads: 1.4M/mo ## What it is and what it does elasticsearch-dbapi bridges Python's standard database API and SQLAlchemy ORM to Elasticsearch and OpenSearch clusters. It translates SQL queries into the native SQL APIs provided by Elastic X-Pack (for Elasticsearch) and OpenSearch SQL plugins, enabling read-only access to indexed data through familiar Python database patterns. The library supports Elasticsearch 7.x, 8.x (with compatibility mode), and OpenSearch 2.x, with special support for AWS Elasticsearch Service. You can use it three ways: directly via DBAPI (connect and cursor), through SQLAlchemy's raw execute interface, or via SQLAlchemy's ORM reflection to introspect indices as tables. Connection strings follow RFC-1738 and accept transport parameters like http_compress and timeout. The library defaults to a 10000-row fetch limit and UTC timezone but allows both to be customized per connection. Use it for: - Query Elasticsearch indices using standard SQL syntax from Python without learning the native query DSL. - Integrate Elasticsearch data into SQLAlchemy-based applications for ORM-style table reflection and queries. - Connect AWS Elasticsearch Service (OpenSearch) clusters to Python analytics or reporting tools via DBAPI. - Build data pipelines that treat Elasticsearch indices as queryable tables alongside traditional SQL databases. - Prototype or migrate applications from SQL databases to Elasticsearch by reusing existing DBAPI-compatible code. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides DBAPI (PEP-249) and SQLAlchemy dialect access to Elasticsearch and OpenSearch clusters via SQL, enabling read-only queries against these search engines. Yes. The package is actively maintained, has no known security vulnerabilities, low install friction, and fills a genuine gap for developers needing SQL access to Elasticsearch or OpenSearch. The permissive Apache License, Version 2.0 poses no adoption barrier. Install it if you need to query Elasticsearch/OpenSearch via SQL or SQLAlchemy; skip it only if you prefer native query DSLs or have no Elasticsearch infrastructure. ## Install pip install elasticsearch-dbapi uv add elasticsearch-dbapi poetry add elasticsearch-dbapi ## Installing elasticsearch-dbapi Before you install: Low friction install with four runtime dependencies (elasticsearch, opensearch-py, packaging, sqlalchemy). Active maintenance with a recent commit on 2026-05-07 and 120 repository stars. License in practice: Apache License, Version 2.0 (permissive) allows use in most projects, including commercial ones, with minimal restrictions beyond attribution and liability disclaimers. Quickstart: pip install elasticsearch-dbapi from sqlalchemy.engine import create_engine engine = create_engine('elasticsearch+http://localhost:9200/') rows = engine.connect().execute('select * from flights LIMIT 10') print([row for row in rows]) Elasticsearch or OpenSearch cluster must be running and accessible at the specified host/port; for Elasticsearch 8.x, set ELASTIC_CLIENT_APIVERSIONING=1 in your Python environment. Verify before relying: - Whether the library handles connection pooling or concurrent query execution efficiently at scale. - Performance characteristics when querying large result sets near the 10000-row default fetch limit. - Compatibility with Elasticsearch 8.x beyond the documented ELASTIC_CLIENT_APIVERSIONING environment variable requirement. ## Package facts - License: Apache License, Version 2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags elasticsearch sql query, sqlalchemy elasticsearch dialect, dbapi elasticsearch connector, opensearch sql access, elasticsearch python sql, aws opensearch sql driver, elasticsearch query interface, elasticsearch, sqlalchemy-dialect, opensearch [View on SkillFed](https://skillfed.io/packages/elasticsearch-dbapi) · [View on PyPI](https://pypi.org/project/elasticsearch-dbapi/)