elasticsearch-dbapi
A DBAPI and SQLAlchemy dialect for Elasticsearch
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- 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.
- 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 · maintenance · safety
Apache License, Version 2.0 (permissive) — Apache License, Version 2.0 (permissive) allows use in most projects, including commercial ones, with minimal restrictions beyond attribution and liability disclaimers.
last release 2026-05-07 (99 days) · last repo commit 2026-05-07 · 120 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,386,514 downloads/mo, #3,972 on PyPI
Alternatives
Verify before relying
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])- 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.
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 on this page. Verify before relying on it.
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
elasticsearch-dbapi on PyPI
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.
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.
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])
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 the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packageselasticsearchopensearch-pypackagingsqlalchemy |
| Maintenance | Actively maintained 99 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,386,514 / month, #3,972 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12 |
Evidence: elasticsearch_dbapi-0.2.13-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “elasticsearch sql query”
- elasticsearch-dbapiProvides DBAPI (PEP-249) and SQLAlchemy dialect access to…
- CMRESHandlerProvides a Python logging handler that sends log records directly to…
- elasticsearch8-dslA high-level Python query builder for Elasticsearch that translates…
Give your agent the search over MCP, or paste the wish link into any chat.
More Front-Ends packages
SQLAlchemy is a Python SQL toolkit and Object Relational Mapper (ORM) that provides both a high-level ORM layer for declarative object persistence and a Core SQL construction system for direct database abstraction and query building.
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Alembic generates and manages database schema migrations for SQLAlchemy applications, handling version control of database structure changes with support for upgrades, downgrades, and auto-generation from model changes.
Install it if you use SQLAlchemy and need to version-control schema changes; skip it only if you manage migrations manually or use a different ORM entirely.
A Python client library for connecting to and querying Weaviate, a vector database that enables semantic search and AI-powered data retrieval.
A Python client library that connects to Databricks clusters and SQL warehouses using a Thrift-based protocol, conforming to the Python DB API 2.0 specification and supporting Arrow-based data exchange.
Install it if you need to query Databricks clusters or SQL warehouses from Python.
Psycopg 3 is a PostgreSQL database adapter for Python that enables applications to connect to, query, and manage PostgreSQL databases using Python code.
Install it if you need to connect Python to PostgreSQL.
See also databricks-dbapi · dbapi · pinotdb · sqlalchemy-databricks · presto-python-client · sqlalchemy-jdbcapi · ibm-db-sa · sqlalchemy-solr · opensearch-py · shillelagh