Files
Joe SpadolaandGitHub 55dcd7db4c Replace pylint with ruff for linting and formatting (#703)
* migrate from pylint to ruff

* ruff format/lint switch over

* add formatting commit

* update changelog
2026-04-02 16:09:59 -07:00

55 lines
1.3 KiB
Python

from clickhouse_connect.dbapi.cursor import Cursor
from clickhouse_connect.driver import create_client
from clickhouse_connect.driver.query import QueryResult
class Connection:
"""
See :ref:`https://peps.python.org/pep-0249/`
"""
def __init__(
self,
dsn: str = None,
username: str = "",
password: str = "",
host: str = None,
database: str = None,
interface: str = None,
port: int = 0,
secure: 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.client._add_integration_tag("sqlalchemy")
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)