This repository contains pinotdb, a Python DB-API 2.0 client and SQLAlchemy dialect for querying Apache Pinot via its SQL API.
- DB-API implementation:
pinotdb/db.py- Entry points:
pinotdb.connect(...),pinotdb.connect_async(...) - Uses
httpxto POST SQL queries to the broker (default path/query/sql).
- Entry points:
- SQLAlchemy dialect:
pinotdb/sqlalchemy.py- Dialects:
PinotHTTPDialect,PinotHTTPSDialect, plus multi-stage variants. - Uses
requeststo fetch metadata from the Pinot controller (e.g./tables,/tables/<table>/schema).
- Dialects:
- Tests:
- Unit tests:
tests/unit/ - Integration tests:
tests/integration/(typically require a running Pinot quickstart)
- Unit tests:
- Examples:
examples/
Declared in pyproject.toml: Python >=3.10,<4.
This repo uses Poetry for dependency management and tox for running tests across multiple Python versions.
- Install deps (dev + extras):
make init- Run tests:
make test- Run unit tests only (fast):
make test-unit- Run integration tests only:
make test-integration- Lint:
make lintThe Make target run-pinot starts a Pinot quickstart container:
make run-pinotNotes:
- The container is named
pinot-quickstartand exposes ports 2123, 9000 (controller), 8000 (broker). - Run
make run-pinotin one terminal, then runmake test-integrationin another.make test-integrationwill fail fast if Pinot isn't reachable onPINOT_HOST:PINOT_BROKER_PORTandPINOT_HOST:PINOT_CONTROLLER_PORT(defaults:localhost:8000andlocalhost:9000). - If you need to restart cleanly, you may have to stop/remove the container (e.g.
docker rm -f pinot-quickstart).
To run the test suite under tox (multi-Python):
toxtox.ini installs Poetry and runs poetry install --all-extras followed by poetry run pytest.
- Prefer small, backwards-compatible changes: this package is a DB-API surface + SQLAlchemy dialect, so parameter names and behavior are hard to change without breaking users.
- Add/adjust tests:
- Pure logic →
tests/unit/ - End-to-end behavior against Pinot →
tests/integration/(requires quickstart)
- Pure logic →
- Keep style consistent: run
make lintand keep new codeflake8-clean. - Be explicit about broker/controller behavior:
- Broker queries go through
httpxinpinotdb/db.py - Controller metadata goes through
requestsinpinotdb/sqlalchemy.py
- Broker queries go through
From README.md:
- Configure PyPI token (one-time):
poetry config pypi-token.pypi <token>- Bump version:
poetry version patch- Build and publish:
poetry build
poetry publishThere is also a GitHub Actions workflow for publishing (see README.md).