Skip to main content

Python client for Mill data services — connect via gRPC or HTTP, query, and consume results as native Python, Arrow, pandas, or polars.

Project description

mill-py (PyPI: qpointz-mill-py)

Python client for Mill data services.

Connect via gRPC or HTTP (JSON / Protobuf), query data with SQL, and consume results as native Python dicts, PyArrow Tables, pandas DataFrames, or polars DataFrames.

Installation

pip install qpointz-mill-py              # core (gRPC + HTTP)
pip install qpointz-mill-py[arrow]       # + PyArrow support
pip install qpointz-mill-py[pandas]      # + pandas (includes Arrow)
pip install qpointz-mill-py[polars]      # + polars (includes Arrow)
pip install qpointz-mill-py[all]         # everything

Requirements: Python 3.10 – 3.13.

Quick Start

from mill import connect

# Connect via gRPC
client = connect("grpc://localhost:9090")

# List schemas
for name in client.list_schemas():
    print(name)

# Run a query
result = client.query('SELECT "ID", "CITY" FROM "skymill"."CITIES"')
for row in result:
    print(row["CITY"])

Connect via HTTP

# HTTP with JSON encoding (default)
client = connect("http://localhost:8080/services/jet")

# HTTP with protobuf encoding (more efficient)
client = connect("http://localhost:8080/services/jet", encoding="protobuf")

Context Manager

with connect("grpc://localhost:9090") as client:
    result = client.query("SELECT 1")
    print(result.fetchall())

Authentication

from mill import connect
from mill.auth import BasicAuth, BearerToken

# Basic auth (username + password)
client = connect("grpc://localhost:9090", auth=BasicAuth("user", "pass"))

# Bearer token (OAuth2 / JWT)
client = connect("grpc://localhost:9090", auth=BearerToken("eyJhbG..."))

# Anonymous (default — no auth header)
client = connect("grpc://localhost:9090")

TLS / Mutual-TLS

# TLS with custom CA certificate
client = connect("grpcs://secure.backend:443", tls_ca="/path/to/ca.pem")

# Mutual-TLS (client certificate + key)
client = connect(
    "grpcs://mtls.backend:443",
    tls_ca="/path/to/ca.pem",
    tls_cert="/path/to/client.pem",
    tls_key="/path/to/client-key.pem",
)

DataFrame Conversion

All DataFrame conversions use PyArrow as the foundation.

result = client.query('SELECT * FROM "skymill"."CITIES"')

# PyArrow Table
table = result.to_arrow()       # requires qpointz-mill-py[arrow]

# pandas DataFrame
df = result.to_pandas()          # requires qpointz-mill-py[pandas]

# polars DataFrame
df = result.to_polars()          # requires qpointz-mill-py[polars]

Async API

The mill.aio module mirrors the synchronous API with async/await.

from mill.aio import connect as aconnect
from mill.auth import BasicAuth

async with await aconnect("grpc://localhost:9090") as client:
    schemas = await client.list_schemas()

    result = await client.query('SELECT * FROM "skymill"."CITIES"')
    async for row in result:
        print(row["CITY"])

    # DataFrame conversion
    df = await result.to_pandas()

Schema Introspection

client = connect("grpc://localhost:9090")

# List schema names
schemas = client.list_schemas()

# Get full schema with tables and fields
schema = client.get_schema("skymill")
for table in schema.tables:
    print(f"{table.schema_name}.{table.name}")
    for field in table.fields:
        print(f"  {field.name}: {field.type.name} (nullable={field.nullable})")

Mill Type System

mill-py supports all 16 Mill logical types with automatic conversion to Python native types:

Mill Type Python Type PyArrow Type
TINY_INT int int8
SMALL_INT int int16
INT int int32
BIG_INT int int64
BOOL bool bool_
FLOAT float float32
DOUBLE float float64
STRING str string
BINARY bytes binary
UUID uuid.UUID binary(16)
DATE datetime.date date32
TIME datetime.time time64('ns')
TIMESTAMP datetime.datetime timestamp('ms')
TIMESTAMP_TZ datetime.datetime (UTC) timestamp('ms', tz='UTC')
INTERVAL_DAY datetime.timedelta duration('s')
INTERVAL_YEAR int int32

Error Handling

from mill import connect, MillConnectionError, MillAuthError, MillQueryError

try:
    client = connect("grpc://localhost:9090")
    result = client.query("SELECT bad syntax")
except MillConnectionError:
    print("Cannot reach the server")
except MillAuthError:
    print("Authentication failed")
except MillQueryError as e:
    print(f"Query failed: {e}")

License

Apache License 2.0. See LICENSE for 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

qpointz_mill_py-0.6.0a82676.tar.gz (78.1 kB view details)

Uploaded Source

Built Distribution

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

qpointz_mill_py-0.6.0a82676-py3-none-any.whl (115.1 kB view details)

Uploaded Python 3

File details

Details for the file qpointz_mill_py-0.6.0a82676.tar.gz.

File metadata

  • Download URL: qpointz_mill_py-0.6.0a82676.tar.gz
  • Upload date:
  • Size: 78.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.19 Linux/5.15.0-170-generic

File hashes

Hashes for qpointz_mill_py-0.6.0a82676.tar.gz
Algorithm Hash digest
SHA256 73748b6b7b392e4eb3f76d31c99243ef7f071b6ff87fb082204fe848b04ac206
MD5 a4a19dce1b64c986b08c9573de30f1fb
BLAKE2b-256 63f8f092fd81e477b0aaf6c80789ac324472cb7c2a50d02f9d441e2875beb8f2

See more details on using hashes here.

File details

Details for the file qpointz_mill_py-0.6.0a82676-py3-none-any.whl.

File metadata

  • Download URL: qpointz_mill_py-0.6.0a82676-py3-none-any.whl
  • Upload date:
  • Size: 115.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.19 Linux/5.15.0-170-generic

File hashes

Hashes for qpointz_mill_py-0.6.0a82676-py3-none-any.whl
Algorithm Hash digest
SHA256 158bcbad40c60cc9a03887b09c713f0dbbcd86d73e42eda180def292e47d351c
MD5 b3ec3c2fa1cc17e5be2589eab0e3260d
BLAKE2b-256 2b63147f326bde393999898f1856ac17184bc90e6efcc4ff1b37c6ba99f1f7dd

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