Python client: streaming and exact types
Server-independent HTTP integration, typed parameters, cursor consumption and network recovery.
HTTP client boundary
The Python client accesses the Core protocol without sharing its interpreter or native libraries. Typed transport preserves BIGINT, DECIMAL, binary and temporal values. Incremental consumption controls application memory; deterministic cursor closure releases server resources. Read and write calls have different recovery rules defined by the sequence contract.
Use HTTP without installing the engine
Your application connects directly to Core over HTTPS. Its OS and Python version need not match the server. The example uses the Python standard library, without pip, nanobind or a Linux ODBC driver. Download octaviius_http.py or the examples ZIP and place the module beside your application.
The HTTP Client interface exposes protocol 3 SELECT and DML with typed parameters, incremental reads, describe, cancel and close. Scripts, procedures and multiple results use the explicit protocol 4 consumption loop in the dedicated reference.
Configure access without hardcoded secrets
Request the Core origin, database and a read key scoped to the required sources. The following variables show expected names; inject the actual key through your secret manager rather than shell history. OCTAVIIUS_DATABASE is a database name, not its server filesystem path.
export OCTAVIIUS_URL="https://db.exemple.fr:9443"
export OCTAVIIUS_DATABASE="Atelier"
# OCTAVIIUS_API_KEY: inject from your secret manager
python3 octaviius_http.py --sql "SELECT 1 AS verification"Read a complete result with exact types
This example uses the Atelier fixture and a key authorized on dbo.Ventes. with closes the cursor after the last row, an error or an early break. Batches are streamed; do not convert an entire large export into a list. BIGINT becomes int, DECIMAL becomes Decimal, binaries become bytes and date/time values become the matching datetime types. NULL stays None; an empty string remains empty.
import os
from decimal import Decimal
from octaviius_http import Client
client = Client(os.environ["OCTAVIIUS_URL"],
api_key=os.environ["OCTAVIIUS_API_KEY"])
caps = client.capabilities()
if 3 not in caps.get("protocol_versions", []):
raise RuntimeError("Protocol 3 required")
with client.query(
"SELECT Id, Montant FROM dbo.Ventes WHERE Montant >= @minimum ORDER BY Id",
database=os.environ["OCTAVIIUS_DATABASE"],
params={"minimum": "10.0000"},
parameter_types={"minimum": {"type": "DECIMAL", "args": [19, 4]}},
batch_rows=8192, timeout=60
) as result:
print(result.columns_meta)
for identifiant, montant in result:
assert isinstance(identifiant, int)
assert isinstance(montant, Decimal)
print(identifiant, montant)Other operations and account authentication
client.describe(sql, database, params, parameter_types) describes a SELECT without reading its data. client.cancel(query_id) requests cancellation. client.query also accepts one INSERT/UPDATE/DELETE; consume it to completion and inspect result.affected_rows. No transaction is offered: successful statements publish independently.
For account authentication, construct Client(url) without a key, call login(user, password), use the same methods and finally logout(). Cookies remain in memory. Do not share a Client across threads without synchronization; use one per workflow. Scripts, procedures and multiple results use protocol 4; this high-level example does not implement them.
Network errors, TLS and retries
HTTPS validates certificates against the client Python trust store. Install your internal CA if necessary; do not disable verification. An HTTP timeout does not prove a write failed. The module never retries /query. It may retry interrupted fetches with the same sequence, bounded by fetch_retries. Cursor expiry requires an application decision; automatic SQL re-execution is not safe by default.
Keep code, sqlstate, request_id and query_id from OctaviiusError. Do not log Authorization, cookies, passwords or sensitive parameters. The example’s historical X-Octaviius-Client: Studio header is a current Core transport convention, not a permission or a dependency on the Studio UI.