Files
zeekay 999d38466d rename: this fork is ours — datastore_connect
Imports read `datastore_connect`, distribution `datastore-connect`, so nothing has to
import another product's name to talk to Hanzo Datastore.

Cut from upstream 0.8.17 — the version this stack already ran — rather than from
upstream HEAD, so it is a PURE RENAME with no behaviour change. Forking from
HEAD would have dragged versions along with the name (connect alone jumped
0.8.17 -> 1.6.0, a major), which is a different and much riskier change wearing
a rename's clothes.

X-ClickHouse-* headers are untouched: they are wire protocol the server sends
and expects, and a different token shape from the module name.
2026-07-26 11:01:30 -07:00

51 lines
1.5 KiB
Python

from typing import Union
from datastore_connect.dbapi.cursor import Cursor
from datastore_connect.driver import create_client
from datastore_connect.driver.query import QueryResult
class Connection:
"""
See :ref:`https://peps.python.org/pep-0249/`
"""
# pylint: disable=too-many-arguments
def __init__(self,
dsn: str = None,
username: str = '',
password: str = '',
host: str = None,
database: str = None,
interface: str = None,
port: int = 0,
secure: Union[bool, str] = False,
**kwargs):
self.client = create_client(host=host,
username=username,
password=password,
database=database,
interface=interface,
port=port,
secure=secure,
dsn=dsn,
generic_args=kwargs)
self.timezone = self.client.server_tz
def close(self):
self.client.close()
def commit(self):
pass
def rollback(self):
pass
def command(self, cmd: str):
return self.client.command(cmd)
def raw_query(self, query: str) -> QueryResult:
return self.client.query(query)
def cursor(self):
return Cursor(self.client)