Skip to main content

Statically typed DB-API 2.0 driver for Apache Pinot

Project description

pinot-connect

codecov unit-tests integration-tests pages-build-deployment License: MIT

Installation

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 for high-performance JSON deserialization
  • httpx 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:

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.

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)
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 for details.

  • Type Mapping
    pinot_connect automatically converts Pinot data types to their Python equivalents. More details are available in the type conversion documentation.

  • 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 or reference docs for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pinot_connect-0.1.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pinot_connect-0.1.0-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file pinot_connect-0.1.0.tar.gz.

File metadata

  • Download URL: pinot_connect-0.1.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1021-azure

File hashes

Hashes for pinot_connect-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bdcefa02473911f7ba8823d25c3f01ed48de5345d8d39ab02dacfdca16c203b9
MD5 c6ed9d2f6733fd8561410eb42735113d
BLAKE2b-256 7ef3c9b2c8b3a84fe1a69fc85e6428586faa5424bc12806461aaafef6d5d609c

See more details on using hashes here.

File details

Details for the file pinot_connect-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pinot_connect-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1021-azure

File hashes

Hashes for pinot_connect-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c609fd519b805742ca4d5c574cc303de38db8d7a4d50eca7deef673bf59218bc
MD5 68e41d97589b1c39618be7b0d37ac5db
BLAKE2b-256 1a40c25a14c92e809352bc3581135143b68920105ed6f6e962de29d1c4825fea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page