Polnor Python SDK
The official Python client for the Polnor lakehouse — query Iceberg tables with SQL, manage notebooks / jobs / models / endpoints, read & write pandas DataFrames, and use the PEP 249 driver for dbt, pandas, sqlalchemy, and any tool that speaks standard Python DB API.
Install
pip install polnor
Quick start
import polnor
# `polnor.sql()` runs against your default warehouse. Inside a Polnor
# notebook or job, credentials are injected automatically. On a laptop,
# set env vars first (see "Auth" below).
result = polnor.sql("SELECT * FROM demo.orders LIMIT 5")
print(result.rows) # list of lists
print(result.to_pandas()) # pandas DataFrame
Auth
The SDK resolves credentials in this order (first match wins):
polnor.set_token("...", api_url="...", warehouse_id="...")— explicit call- Environment variables:
POLNOR_API_URL,POLNOR_TOKEN,POLNOR_WAREHOUSE_ID ~/.polnor/config.toml— TOML config file written by thepolnorCLI
Inside a Polnor notebook or job, all three POLNOR_ env vars are injected
by the runtime* — your cell-1 polnor.sql(...) works with no setup.
Local example (TOML config):
# ~/.polnor/config.toml
host = "https://api.polnor.net"
token = "<personal access token>"
workspace_id = "<your workspace>"
warehouse_id = "<your default warehouse>"
What's in the box
| Module | What it does |
|---|---|
polnor.sql(query) |
Run SQL on a SQL warehouse, return rows / pandas / dicts. |
polnor.warehouses |
List / get / start / stop / default SQL warehouses. |
polnor.compute |
Manage compute VMs (start, stop, install_library, logs). |
polnor.notebooks |
Create / start / stop Jupyter notebooks on a compute. |
polnor.jobs |
Create + run DAG jobs, fetch logs, cancel, wait. |
polnor.models |
Model registry: versions, artifact URIs, framework tags. |
polnor.endpoints |
Serve a model image: deploy, predict, scale, stop. |
polnor.tables |
Browse databases (Iceberg namespaces) and tables. |
polnor.read_pandas |
Read a table (with where=, limit=) into a DataFrame. |
polnor.write_pandas |
Bulk-insert a DataFrame (append / overwrite / create). |
polnor.dbapi |
PEP 249 driver: connect() / cursor() for dbt / pandas. |
polnor.mlflow |
MLflow-compatible tracking: log_param, log_metric, etc. |
Examples
SQL → pandas DataFrame
df = polnor.sql("SELECT region, COUNT(*) c FROM demo.orders GROUP BY region").to_pandas()
df.plot(kind="bar")
Push a DataFrame to a table
import pandas as pd
df = pd.DataFrame({"id": [1, 2, 3], "name": ["alice", "bob", "carol"]})
polnor.write_pandas(df, "polnor.demo.default.users", mode="create")
PEP 249 (works with dbt, pandas.read_sql, sqlalchemy)
import pandas as pd
import polnor.dbapi as dbapi
conn = dbapi.connect()
df = pd.read_sql("SELECT * FROM demo.orders", conn)
Notebooks, jobs, models, endpoints
# Start a notebook on a CPU compute
polnor.compute.start("my-cpu", wait=True)
nb = polnor.notebooks.create(name="explore", compute_id="my-cpu")
polnor.notebooks.start("explore", wait=True)
# Run a DAG job
job = polnor.jobs.create(name="etl", tasks=[
{"key": "extract", "command": "python extract.py", "image": "python:3.11"},
{"key": "transform", "command": "python transform.py", "image": "python:3.11",
"depends_on": ["extract"]},
])
run_id = polnor.jobs.run("etl")
polnor.jobs.wait(run_id)
print(polnor.jobs.logs(run_id))
# Serve a model
polnor.endpoints.create(name="fraud-v1", image="my-registry/fraud:1.0",
environment={"CONTAINER_PORT": "8080"})
polnor.endpoints.deploy("fraud-v1", wait=True)
pred = polnor.endpoints.predict("fraud-v1", inputs=[[0.1, 0.2, 0.3]])
MLflow-compatible tracking
from polnor import mlflow
with mlflow.start_run() as run:
mlflow.log_param("lr", 0.01)
mlflow.log_metric("accuracy", 0.93)
mlflow.log_artifact("./model.pkl")
Errors
The SDK raises these typed exceptions:
polnor.PolnorAPIError— non-2xx HTTP from the control plane.polnor.SQLError— statement failed, cancelled, or timed out.polnor.PolnorConfigError— no credentials could be resolved.polnor.dbapi.ProgrammingError/OperationalError/ etc. — PEP 249 hierarchy.
Compatibility
- Python ≥ 3.9 (
tomlifalls in for 3.9 / 3.10; 3.11+ hastomllibbuilt in) - pandas integration: optional, lazily imported
- dbt: works via
polnor.dbapi(a dedicateddbt-polnoradapter is in V2)
Development
pip install -e ".[test]"
pytest
Tests use responses to mock HTTP —
no live API needed. The tests/test_e2e_prod.py suite (opt-in via env)
hits api.polnor.net and requires a running warehouse + valid PAT.
Links
- Homepage: https://polnor.net
- API docs: https://docs.polnor.net
- Source / issues: https://github.com/polnor/polnor
License
Apache-2.0.
Metadata
Release files for polnor 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polnor-1.5.0.tar.gz | 54.7 kB | Without provenance | Details for polnor-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polnor-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for polnor-1.5.0-py3-none-any.whl |
Total release size: 108.1 kB
Release files / polnor-1.5.0.tar.gz
| Download URL | polnor-1.5.0.tar.gz |
|---|---|
| Size | 54.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57e340aa748ca1a75014f0d349b174208f8d902db6011570ad87e3a53ccce5c5
|
|
BLAKE2b-256 checksum How to use checksums |
ee996bd388db2defd4f7883d9752d399251a0fca81f91854f3241eaab0c8a684
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / polnor-1.5.0-py3-none-any.whl
| Download URL | polnor-1.5.0-py3-none-any.whl |
|---|---|
| Size | 53.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b6df336fa9c4ddb5107b70423cd51033bc542d29fe994f32a3170a5627c2624
|
|
BLAKE2b-256 checksum How to use checksums |
08f591fdae3211f8a4cf9ff5cefab5bedab6d28c8346fc752b3b7b825a6e0e19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for polnor 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.