aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/clickhouse-connect/clickhouse_connect/dbapi/__init__.py
blob: ea792b49683ed3ebf6dd6b09146029c982716363 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from typing import Optional

from clickhouse_connect.dbapi.connection import Connection


apilevel = '2.0'         # PEP 249  DB API level
threadsafety = 2         # PEP 249  Threads may share the module and connections.
paramstyle = 'pyformat'  # PEP 249  Python extended format codes, e.g. ...WHERE name=%(name)s


class Error(Exception):
    pass


def connect(host: Optional[str] = None,
            database: Optional[str] = None,
            username: Optional[str] = '',
            password: Optional[str] = '',
            port: Optional[int] = None,
            **kwargs):
    secure = kwargs.pop('secure', False)
    return Connection(host=host,
                      database=database,
                      username=username,
                      password=password,
                      port=port,
                      secure=secure,
                      **kwargs)