Metadata-Version: 2.3
Name: pinot-connect
Version: 0.1.0
Summary: Statically typed DB-API 2.0 driver for Apache Pinot
License: MIT
Author: Zach Schumacher
Author-email: zschu15@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development
Classifier: Topic :: Database
Classifier: Topic :: Database :: Database Engines/Servers
Classifier: Typing :: Typed
Requires-Dist: ciso8601 (>=2.3.2,<3.0.0)
Requires-Dist: httpx (>=0.23.0,<0.29.0)
Requires-Dist: orjson (>=3.10.15,<4.0.0)
Project-URL: Changelog, https://pinot-connect.org/release_notes
Project-URL: Documentation, https://pinot-connect.org/
Project-URL: Homepage, https://github.com/zschumacher/pinot-connect
Project-URL: Issues, https://github.com/zschumacher/pinot-connect/issues
Project-URL: Repository, https://github.com/zschumacher/pinot-connect
Description-Content-Type: text/markdown

# pinot-connect

[![codecov](https://codecov.io/gh/zschumacher/pinot-connect/graph/badge.svg?token=bQLhy9S1GT)](https://codecov.io/gh/zschumacher/pinot-connect)
[![unit-tests](https://github.com/zschumacher/pinot-connect/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/zschumacher/pinot-connect/actions/workflows/unit-tests.yml)
[![integration-tests](https://github.com/zschumacher/pinot-connect/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/zschumacher/pinot-connect/actions/workflows/integration-tests.yml)
[![pages-build-deployment](https://github.com/zschumacher/pinot-connect/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/zschumacher/pinot-connect/actions/workflows/pages/pages-build-deployment)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Installation
```shell
pip install pinot-connect
# or
poetry add pinot-connect
# or
uv add pinot-connect
```

## Overview
**pinot_connect** is a **DB-API 2.0 compliant** and **statically typed** driver for querying **Apache Pinot** with 
Python. It supports both **synchronous** and **asynchronous** execution, making it flexible for a variety of 
applications.

Powered by:

- [**orjson**](https://github.com/ijl/orjson) for **high-performance JSON deserialization**
- [**httpx**](https://www.python-httpx.org) for **async support and connection pooling**

`pinot_connect` outperforms `pinotdb` in benchmarks.  On average for queries that return 100 or more rows, you can 
expect to see ~15-30% faster execution. 

---
## Documentation
The full documentation can be found [here]().

---
## Quickstart

### Running a quick start Pinot cluster
To start an Apache Pinot cluster with example data, run:
```shell
docker run -d --name pinot-quickstart -p 9000:9000 \
  -p 8099:8000 \
  --health-cmd="curl -f http://localhost:9000/health || exit 1" \
  --health-interval=10s \
  --health-timeout=5s \
  --health-retries=5 \
  --health-start-period=10s \
  apachepinot/pinot:latest QuickStart -type batch
```
This command launches a Pinot instance with preloaded batch data, making it easy to start querying right away.

### Querying with `pinot_connect`
Once your cluster is up and running, you can query it using pinot_connect. Below are examples for both synchronous and 
asynchronous usage.

``` py title="Sync example"
import pinot_connect
from pinot_connect.rows import dict_row

with pinot_connect.connect(host="localhost") as conn:
    with conn.cursor(row_factory=dict_row) as cursor:
        cursor.execute("select * from airlineStats limit 100")
        for row in cursor:
            print(row)
```

``` py title="Async example"
import pinot_connect
from pinot_connect.rows import dict_row
import asyncio

async def main():
    async with pinot_connect.AsyncConnection.connect(hose="localhost") as conn:
        async with conn.cursor(row_factory=dict_row) as cursor:
            await cursor.execute("select * from airlineStats limit 100")
            async for row in cursor:
                print(row)

asyncio.run(main())
```

**What's Happening Here?**

- **Standard DB-API 2.0 Interface**  
  `pinot_connect` provides a familiar connection and cursor interface, similar to popular Python database clients such as
  `sqlite3` or `psycopg`

- **Row Factories**  
  The `row_factory` parameter lets you customize how rows are returned. In this example, `dict_row` returns results as
  dictionaries. You can choose from built-in factories or define your own. See the 
  [**row factories documentation**](usage/row_factories.md) for details.

- **Type Mapping**  
  `pinot_connect` automatically converts Pinot data types to their Python equivalents. More details are available in the 
  [**type conversion documentation**](usage/type_conversion.md).

- **Cursor Iteration & Fetch Methods**  
  You can iterate over results directly or use `fetchone()`, `fetchmany()`, `fetchall()`, and `scroll()`, following the 
  DB-API spec. See the [**usage docs**](usage) or [**reference docs**](reference/cursor.md) for more details.


