frostlake-connector
A high-level Python client for Frostlake, built on the
frostlake PEP 249 driver.
Where the driver is a minimal DB-API surface, this package adds the conveniences an
application usually wants: %s and %(name)s binding, dict-shaped rows, multi-statement
scripts, session setup on connect, and a full exception hierarchy.
pip install frostlake-connector
The driver comes along as a dependency and speaks Frostlake's HTTP protocol, so no JVM is needed on the client.
Engine version
Requires a Frostlake engine 0.0.7 or newer. Ask a running server which one it is with
SELECT CURRENT_VERSION() — every release answers it, so the check works against any engine.
The client versions independently of the engine: it speaks the HTTP protocol, not the jar, so this is a floor rather than a lockstep pin.
Usage
import frostlake_connector
conn = frostlake_connector.connect(host="localhost", port=18082,
database="MY_DB", schema="PUBLIC",
warehouse="COMPUTE_WH",
session_parameters={"QUERY_TAG": "ci"})
cur = conn.cursor()
cur.execute("SELECT id, name FROM people WHERE id = %s", (1,))
print(cur.fetchall()) # [(1, 'Ada')]
What it covers
connect(**kwargs)—host/portselect the server;role,warehouse,databaseandschemabecomeUSEstatements (in that order) andsession_parameters/timezonebecomeALTER SESSION SET. Unrecognised keywords are accepted and ignored, so a configuration carried over from another warehouse still loads. Those names fold like unquoted SQL —database="my_db"selectsMY_DB— so include the double quotes (database='"my_db"') to reach an object whose real name is not upper case.- Cursors:
execute(returns the cursor),executemany,fetchone/fetchmany/fetchall,nextsetfor multi-statement results, iteration, context-manager use,rowcountfrom DML, andquery_id.DictCursorreturns dicts instead of tuples. A script handed toexecutewhole travels as one request, and a session runs one statement per request until something asks for more:execute(sql, num_statements=n)declares the count for that one call (0for any number), as the account's connector does, and leaves the session's ownMULTI_STATEMENT_COUNTwhere it was, whileALTER SESSION SET MULTI_STATEMENT_COUNT = nsets it for the session;execute_stringsplits the script client-side instead, so it needs neither. - Descriptions:
ResultMetadata(name, type_code, display_size, internal_size, precision, scale, is_nullable), wheretype_codeis a numeric family code — seeconstants.FIELD_ID_TO_NAME— so callers can branch without parsing SQL type text.internal_sizecarries the column's length — characters for text, bytes for binary — when the server sends one, and staysNonefor other types and for engines predating the field.display_sizeis alwaysNone, as in the account's own Python client. - Binding:
pyformatby default (%s,%(name)s,%%), orparamstyle="qmark"for?. Placeholders inside string literals, quoted identifiers, comments and$$…$$bodies are left alone. execute_string()splits a script on top-level semicolons — respecting$$…$$procedure bodies — and returns one cursor per statement.- Transactions:
autocommit(mode),commit(),rollback(). With autocommit off the connection stays transactional: ending one transaction opens the next. is_closed(),session_id, and connections as context managers.- Errors: a PEP 249 hierarchy in
frostlake_connector.errors— everything derives fromError, database failures fromDatabaseError. Each carriesmsg,errno,sqlstate,query_idandquery; engine compile errors arrive asProgrammingError(errno=1003, sqlstate="42000"), with the engine's message text authoritative.
Running the tests
export JAVA_HOME=/path/to/jdk17
export FROSTLAKE_CLASSPATH="/path/to/frostlake-db.jar:<engine deps>"
python3 test/test_facade.py
The suite boots a real DatabaseHttpServer and covers connect-kwargs context
(CURRENT_DATABASE/CURRENT_SCHEMA/CURRENT_WAREHOUSE), binding in both paramstyles,
descriptions and type codes, DictCursor, executemany, execute_string, transaction
discipline and the error surface. Without FROSTLAKE_CLASSPATH the integration tests skip
and the unit tests still run.
Related
frostlake— the PEP 249 driver underneath.dbt-frostlake— the dbt adapter, which uses this client as its transport.
Metadata
Release files for frostlake-connector 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| frostlake_connector-0.2.1.tar.gz | 24.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| frostlake_connector-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.2 kB
Release files / frostlake_connector-0.2.1.tar.gz
| Download URL | frostlake_connector-0.2.1.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8700d7c8baabb7d2bc80a100c59321452d0e1a86eb9484198c1074134f38880e
|
|
BLAKE2b-256 checksum How to use checksums |
a31222491ae68fa1ee215011352eb8ea08329c16fa742942e1bf5fde8106aced
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / frostlake_connector-0.2.1-py3-none-any.whl
| Download URL | frostlake_connector-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
329a9822ae2ec457090bf2997b5283ee23b5c80ffc8af20892fd677033395b1b
|
|
BLAKE2b-256 checksum How to use checksums |
b0ff971450884aff174d7a9e38f61affc88d12279ca1d682c1d8eea6d32b7ccb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|