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.1.tar.gz (19.2 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.1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pinot_connect-0.1.1.tar.gz
  • Upload date:
  • Size: 19.2 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.1.tar.gz
Algorithm Hash digest
SHA256 db145b4512ad4715979fd48f4eac44e422f2d9effe22b30b8fb631f44ef9a548
MD5 fad193ae1f183d8960e6a4b41a442917
BLAKE2b-256 169fc5338b087287c9a3bab63fa744aeaa43508a54a4132cfcbf51559fa4ed1d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pinot_connect-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb0b2ea8ccb394617a79e490d1f0e2f1603a55f4e06cd1ed0830b91ca2de1080
MD5 ccc8b8334eafc62eb49251c86eaff99d
BLAKE2b-256 1f0e934c695c89cff858b8732e5f25c9494b89b8dcd5b3e7297d6eaaf0abf993

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