clickhouse-driver 0.2.1__cp39-cp39-win_amd64.whl → 0.2.10__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clickhouse_driver/__init__.py +9 -9
- clickhouse_driver/block.py +227 -195
- clickhouse_driver/blockstreamprofileinfo.py +22 -22
- clickhouse_driver/bufferedreader.cp39-win_amd64.pyd +0 -0
- clickhouse_driver/bufferedwriter.cp39-win_amd64.pyd +0 -0
- clickhouse_driver/client.py +812 -666
- clickhouse_driver/clientinfo.py +119 -80
- clickhouse_driver/columns/arraycolumn.py +161 -150
- clickhouse_driver/columns/base.py +221 -147
- clickhouse_driver/columns/boolcolumn.py +7 -0
- clickhouse_driver/columns/datecolumn.py +108 -49
- clickhouse_driver/columns/datetimecolumn.py +203 -207
- clickhouse_driver/columns/decimalcolumn.py +116 -118
- clickhouse_driver/columns/enumcolumn.py +129 -119
- clickhouse_driver/columns/exceptions.py +12 -12
- clickhouse_driver/columns/floatcolumn.py +34 -34
- clickhouse_driver/columns/intcolumn.py +157 -157
- clickhouse_driver/columns/intervalcolumn.py +33 -33
- clickhouse_driver/columns/ipcolumn.py +118 -118
- clickhouse_driver/columns/jsoncolumn.py +37 -0
- clickhouse_driver/columns/largeint.cp39-win_amd64.pyd +0 -0
- clickhouse_driver/columns/lowcardinalitycolumn.py +142 -123
- clickhouse_driver/columns/mapcolumn.py +73 -58
- clickhouse_driver/columns/nestedcolumn.py +10 -0
- clickhouse_driver/columns/nothingcolumn.py +13 -13
- clickhouse_driver/columns/nullablecolumn.py +7 -7
- clickhouse_driver/columns/nullcolumn.py +15 -15
- clickhouse_driver/columns/numpy/base.py +47 -14
- clickhouse_driver/columns/numpy/boolcolumn.py +8 -0
- clickhouse_driver/columns/numpy/datecolumn.py +19 -12
- clickhouse_driver/columns/numpy/datetimecolumn.py +146 -145
- clickhouse_driver/columns/numpy/floatcolumn.py +24 -13
- clickhouse_driver/columns/numpy/intcolumn.py +43 -43
- clickhouse_driver/columns/numpy/lowcardinalitycolumn.py +96 -83
- clickhouse_driver/columns/numpy/service.py +58 -80
- clickhouse_driver/columns/numpy/stringcolumn.py +78 -76
- clickhouse_driver/columns/numpy/tuplecolumn.py +37 -0
- clickhouse_driver/columns/service.py +185 -131
- clickhouse_driver/columns/simpleaggregatefunctioncolumn.py +7 -7
- clickhouse_driver/columns/stringcolumn.py +73 -73
- clickhouse_driver/columns/tuplecolumn.py +63 -65
- clickhouse_driver/columns/util.py +61 -0
- clickhouse_driver/columns/uuidcolumn.py +64 -64
- clickhouse_driver/compression/__init__.py +32 -28
- clickhouse_driver/compression/base.py +87 -52
- clickhouse_driver/compression/lz4.py +21 -55
- clickhouse_driver/compression/lz4hc.py +9 -9
- clickhouse_driver/compression/zstd.py +20 -51
- clickhouse_driver/connection.py +825 -632
- clickhouse_driver/context.py +36 -36
- clickhouse_driver/dbapi/__init__.py +62 -62
- clickhouse_driver/dbapi/connection.py +99 -96
- clickhouse_driver/dbapi/cursor.py +370 -368
- clickhouse_driver/dbapi/errors.py +40 -40
- clickhouse_driver/dbapi/extras.py +73 -0
- clickhouse_driver/defines.py +58 -42
- clickhouse_driver/errors.py +453 -446
- clickhouse_driver/log.py +48 -44
- clickhouse_driver/numpy/block.py +8 -8
- clickhouse_driver/numpy/helpers.py +28 -25
- clickhouse_driver/numpy/result.py +123 -123
- clickhouse_driver/opentelemetry.py +43 -0
- clickhouse_driver/progress.py +44 -32
- clickhouse_driver/protocol.py +130 -105
- clickhouse_driver/queryprocessingstage.py +8 -8
- clickhouse_driver/reader.py +69 -69
- clickhouse_driver/readhelpers.py +26 -26
- clickhouse_driver/result.py +144 -144
- clickhouse_driver/settings/available.py +405 -405
- clickhouse_driver/settings/types.py +50 -50
- clickhouse_driver/settings/writer.py +34 -29
- clickhouse_driver/streams/compressed.py +88 -88
- clickhouse_driver/streams/native.py +108 -90
- clickhouse_driver/util/compat.py +39 -0
- clickhouse_driver/util/escape.py +94 -55
- clickhouse_driver/util/helpers.py +173 -57
- clickhouse_driver/varint.cp39-win_amd64.pyd +0 -0
- clickhouse_driver/writer.py +67 -67
- clickhouse_driver-0.2.10.dist-info/METADATA +215 -0
- clickhouse_driver-0.2.10.dist-info/RECORD +89 -0
- {clickhouse_driver-0.2.1.dist-info → clickhouse_driver-0.2.10.dist-info}/WHEEL +1 -1
- {clickhouse_driver-0.2.1.dist-info → clickhouse_driver-0.2.10.dist-info/licenses}/LICENSE +21 -21
- clickhouse_driver-0.2.1.dist-info/METADATA +0 -24
- clickhouse_driver-0.2.1.dist-info/RECORD +0 -80
- {clickhouse_driver-0.2.1.dist-info → clickhouse_driver-0.2.10.dist-info}/top_level.txt +0 -0
clickhouse_driver/context.py
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
class Context(object):
|
|
3
|
-
def __init__(self):
|
|
4
|
-
self._server_info = None
|
|
5
|
-
self._settings = None
|
|
6
|
-
self._client_settings = None
|
|
7
|
-
super(Context, self).__init__()
|
|
8
|
-
|
|
9
|
-
@property
|
|
10
|
-
def server_info(self):
|
|
11
|
-
return self._server_info
|
|
12
|
-
|
|
13
|
-
@server_info.setter
|
|
14
|
-
def server_info(self, value):
|
|
15
|
-
self._server_info = value
|
|
16
|
-
|
|
17
|
-
@property
|
|
18
|
-
def settings(self):
|
|
19
|
-
return self._settings.copy()
|
|
20
|
-
|
|
21
|
-
@settings.setter
|
|
22
|
-
def settings(self, value):
|
|
23
|
-
self._settings = value.copy()
|
|
24
|
-
|
|
25
|
-
@property
|
|
26
|
-
def client_settings(self):
|
|
27
|
-
return self._client_settings.copy()
|
|
28
|
-
|
|
29
|
-
@client_settings.setter
|
|
30
|
-
def client_settings(self, value):
|
|
31
|
-
self._client_settings = value.copy()
|
|
32
|
-
|
|
33
|
-
def __repr__(self):
|
|
34
|
-
return '<Context(server_info=%s, client_settings=%s, settings=%s)>' % (
|
|
35
|
-
self._server_info, self._client_settings, self._settings
|
|
36
|
-
)
|
|
1
|
+
|
|
2
|
+
class Context(object):
|
|
3
|
+
def __init__(self):
|
|
4
|
+
self._server_info = None
|
|
5
|
+
self._settings = None
|
|
6
|
+
self._client_settings = None
|
|
7
|
+
super(Context, self).__init__()
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def server_info(self):
|
|
11
|
+
return self._server_info
|
|
12
|
+
|
|
13
|
+
@server_info.setter
|
|
14
|
+
def server_info(self, value):
|
|
15
|
+
self._server_info = value
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def settings(self):
|
|
19
|
+
return self._settings.copy()
|
|
20
|
+
|
|
21
|
+
@settings.setter
|
|
22
|
+
def settings(self, value):
|
|
23
|
+
self._settings = value.copy()
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def client_settings(self):
|
|
27
|
+
return self._client_settings.copy()
|
|
28
|
+
|
|
29
|
+
@client_settings.setter
|
|
30
|
+
def client_settings(self, value):
|
|
31
|
+
self._client_settings = value.copy()
|
|
32
|
+
|
|
33
|
+
def __repr__(self):
|
|
34
|
+
return '<Context(server_info=%s, client_settings=%s, settings=%s)>' % (
|
|
35
|
+
self._server_info, self._client_settings, self._settings
|
|
36
|
+
)
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
from .connection import Connection
|
|
2
|
-
from .errors import (
|
|
3
|
-
Warning, Error, DataError, DatabaseError, ProgrammingError, IntegrityError,
|
|
4
|
-
InterfaceError, InternalError, NotSupportedError, OperationalError
|
|
5
|
-
)
|
|
6
|
-
from .. import defines
|
|
7
|
-
|
|
8
|
-
apilevel = '2.0'
|
|
9
|
-
|
|
10
|
-
threadsafety = 2
|
|
11
|
-
|
|
12
|
-
paramstyle = 'pyformat'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def connect(dsn=None, host=None,
|
|
16
|
-
user=defines.DEFAULT_USER, password=defines.DEFAULT_PASSWORD,
|
|
17
|
-
port=defines.DEFAULT_PORT, database=defines.DEFAULT_DATABASE,
|
|
18
|
-
**kwargs):
|
|
19
|
-
"""
|
|
20
|
-
Create a new database connection.
|
|
21
|
-
|
|
22
|
-
The connection can be specified via DSN:
|
|
23
|
-
|
|
24
|
-
``conn = connect("clickhouse://localhost/test?param1=value1&...")``
|
|
25
|
-
|
|
26
|
-
or using database and credentials arguments:
|
|
27
|
-
|
|
28
|
-
``conn = connect(database="test", user="default", password="default",
|
|
29
|
-
host="localhost", **kwargs)``
|
|
30
|
-
|
|
31
|
-
The basic connection parameters are:
|
|
32
|
-
|
|
33
|
-
- *host*: host with running ClickHouse server.
|
|
34
|
-
- *port*: port ClickHouse server is bound to.
|
|
35
|
-
- *database*: database connect to.
|
|
36
|
-
- *user*: database user.
|
|
37
|
-
- *password*: user's password.
|
|
38
|
-
|
|
39
|
-
See defaults in :data:`~clickhouse_driver.connection.Connection`
|
|
40
|
-
constructor.
|
|
41
|
-
|
|
42
|
-
DSN or host is required.
|
|
43
|
-
|
|
44
|
-
Any other keyword parameter will be passed to the underlying Connection
|
|
45
|
-
class.
|
|
46
|
-
|
|
47
|
-
:return: a new connection.
|
|
48
|
-
"""
|
|
49
|
-
|
|
50
|
-
if dsn is None and host is None:
|
|
51
|
-
raise ValueError('host or dsn is required')
|
|
52
|
-
|
|
53
|
-
return Connection(dsn=dsn, user=user, password=password, host=host,
|
|
54
|
-
port=port, database=database, **kwargs)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
__all__ = [
|
|
58
|
-
'connect',
|
|
59
|
-
'Warning', 'Error', 'DataError', 'DatabaseError', 'ProgrammingError',
|
|
60
|
-
'IntegrityError', 'InterfaceError', 'InternalError', 'NotSupportedError',
|
|
61
|
-
'OperationalError'
|
|
62
|
-
]
|
|
1
|
+
from .connection import Connection
|
|
2
|
+
from .errors import (
|
|
3
|
+
Warning, Error, DataError, DatabaseError, ProgrammingError, IntegrityError,
|
|
4
|
+
InterfaceError, InternalError, NotSupportedError, OperationalError
|
|
5
|
+
)
|
|
6
|
+
from .. import defines
|
|
7
|
+
|
|
8
|
+
apilevel = '2.0'
|
|
9
|
+
|
|
10
|
+
threadsafety = 2
|
|
11
|
+
|
|
12
|
+
paramstyle = 'pyformat'
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def connect(dsn=None, host=None,
|
|
16
|
+
user=defines.DEFAULT_USER, password=defines.DEFAULT_PASSWORD,
|
|
17
|
+
port=defines.DEFAULT_PORT, database=defines.DEFAULT_DATABASE,
|
|
18
|
+
**kwargs):
|
|
19
|
+
"""
|
|
20
|
+
Create a new database connection.
|
|
21
|
+
|
|
22
|
+
The connection can be specified via DSN:
|
|
23
|
+
|
|
24
|
+
``conn = connect("clickhouse://localhost/test?param1=value1&...")``
|
|
25
|
+
|
|
26
|
+
or using database and credentials arguments:
|
|
27
|
+
|
|
28
|
+
``conn = connect(database="test", user="default", password="default",
|
|
29
|
+
host="localhost", **kwargs)``
|
|
30
|
+
|
|
31
|
+
The basic connection parameters are:
|
|
32
|
+
|
|
33
|
+
- *host*: host with running ClickHouse server.
|
|
34
|
+
- *port*: port ClickHouse server is bound to.
|
|
35
|
+
- *database*: database connect to.
|
|
36
|
+
- *user*: database user.
|
|
37
|
+
- *password*: user's password.
|
|
38
|
+
|
|
39
|
+
See defaults in :data:`~clickhouse_driver.connection.Connection`
|
|
40
|
+
constructor.
|
|
41
|
+
|
|
42
|
+
DSN or host is required.
|
|
43
|
+
|
|
44
|
+
Any other keyword parameter will be passed to the underlying Connection
|
|
45
|
+
class.
|
|
46
|
+
|
|
47
|
+
:return: a new connection.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
if dsn is None and host is None:
|
|
51
|
+
raise ValueError('host or dsn is required')
|
|
52
|
+
|
|
53
|
+
return Connection(dsn=dsn, user=user, password=password, host=host,
|
|
54
|
+
port=port, database=database, **kwargs)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
__all__ = [
|
|
58
|
+
'connect',
|
|
59
|
+
'Warning', 'Error', 'DataError', 'DatabaseError', 'ProgrammingError',
|
|
60
|
+
'IntegrityError', 'InterfaceError', 'InternalError', 'NotSupportedError',
|
|
61
|
+
'OperationalError'
|
|
62
|
+
]
|
|
@@ -1,96 +1,99 @@
|
|
|
1
|
-
from ..client import Client
|
|
2
|
-
from .. import defines
|
|
3
|
-
from .cursor import Cursor
|
|
4
|
-
from .errors import InterfaceError
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Connection(object):
|
|
8
|
-
"""
|
|
9
|
-
Creates new Connection for accessing ClickHouse database.
|
|
10
|
-
|
|
11
|
-
Connection is just wrapper for handling multiple cursors (clients) and
|
|
12
|
-
do not initiate actual connections to the ClickHouse server.
|
|
13
|
-
|
|
14
|
-
See parameters description in
|
|
15
|
-
:data:`~clickhouse_driver.connection.Connection`.
|
|
16
|
-
"""
|
|
17
|
-
def __init__(self, dsn=None, host=None,
|
|
18
|
-
user=defines.DEFAULT_USER, password=defines.DEFAULT_PASSWORD,
|
|
19
|
-
port=defines.DEFAULT_PORT, database=defines.DEFAULT_DATABASE,
|
|
20
|
-
**kwargs):
|
|
21
|
-
self.cursors = []
|
|
22
|
-
|
|
23
|
-
self.dsn = dsn
|
|
24
|
-
self.user = user
|
|
25
|
-
self.password = password
|
|
26
|
-
self.host = host
|
|
27
|
-
self.port = port
|
|
28
|
-
self.database = database
|
|
29
|
-
self.connection_kwargs = kwargs
|
|
30
|
-
self.is_closed = False
|
|
31
|
-
self._hosts = None
|
|
32
|
-
super(Connection, self).__init__()
|
|
33
|
-
|
|
34
|
-
def __repr__(self):
|
|
35
|
-
return '<connection object at 0x{0:x}; closed: {1:}>'.format(
|
|
36
|
-
id(self), self.is_closed
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
# Context manager integrations.
|
|
40
|
-
def __enter__(self):
|
|
41
|
-
return self
|
|
42
|
-
|
|
43
|
-
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
44
|
-
self.close()
|
|
45
|
-
|
|
46
|
-
def _make_client(self):
|
|
47
|
-
"""
|
|
48
|
-
:return: a new Client instance.
|
|
49
|
-
"""
|
|
50
|
-
if self.dsn is not None:
|
|
51
|
-
return Client.from_url(self.dsn)
|
|
52
|
-
|
|
53
|
-
return Client(self.host, port=self.port,
|
|
54
|
-
user=self.user, password=self.password,
|
|
55
|
-
database=self.database, **self.connection_kwargs)
|
|
56
|
-
|
|
57
|
-
def close(self):
|
|
58
|
-
"""
|
|
59
|
-
Close the connection now. The connection will be unusable from this
|
|
60
|
-
point forward; an :data:`~clickhouse_driver.dbapi.Error` (or subclass)
|
|
61
|
-
exception will be raised if any operation is attempted with the
|
|
62
|
-
connection. The same applies to all cursor objects trying to use the
|
|
63
|
-
connection.
|
|
64
|
-
"""
|
|
65
|
-
for cursor in self.cursors:
|
|
66
|
-
cursor.close()
|
|
67
|
-
|
|
68
|
-
self.is_closed = True
|
|
69
|
-
|
|
70
|
-
def commit(self):
|
|
71
|
-
"""
|
|
72
|
-
Do nothing since ClickHouse has no transactions.
|
|
73
|
-
"""
|
|
74
|
-
pass
|
|
75
|
-
|
|
76
|
-
def rollback(self):
|
|
77
|
-
"""
|
|
78
|
-
Do nothing since ClickHouse has no transactions.
|
|
79
|
-
"""
|
|
80
|
-
pass
|
|
81
|
-
|
|
82
|
-
def cursor(self):
|
|
83
|
-
"""
|
|
84
|
-
:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
client.connection.hosts
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
1
|
+
from ..client import Client
|
|
2
|
+
from .. import defines
|
|
3
|
+
from .cursor import Cursor
|
|
4
|
+
from .errors import InterfaceError
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Connection(object):
|
|
8
|
+
"""
|
|
9
|
+
Creates new Connection for accessing ClickHouse database.
|
|
10
|
+
|
|
11
|
+
Connection is just wrapper for handling multiple cursors (clients) and
|
|
12
|
+
do not initiate actual connections to the ClickHouse server.
|
|
13
|
+
|
|
14
|
+
See parameters description in
|
|
15
|
+
:data:`~clickhouse_driver.connection.Connection`.
|
|
16
|
+
"""
|
|
17
|
+
def __init__(self, dsn=None, host=None,
|
|
18
|
+
user=defines.DEFAULT_USER, password=defines.DEFAULT_PASSWORD,
|
|
19
|
+
port=defines.DEFAULT_PORT, database=defines.DEFAULT_DATABASE,
|
|
20
|
+
**kwargs):
|
|
21
|
+
self.cursors = []
|
|
22
|
+
|
|
23
|
+
self.dsn = dsn
|
|
24
|
+
self.user = user
|
|
25
|
+
self.password = password
|
|
26
|
+
self.host = host
|
|
27
|
+
self.port = port
|
|
28
|
+
self.database = database
|
|
29
|
+
self.connection_kwargs = kwargs
|
|
30
|
+
self.is_closed = False
|
|
31
|
+
self._hosts = None
|
|
32
|
+
super(Connection, self).__init__()
|
|
33
|
+
|
|
34
|
+
def __repr__(self):
|
|
35
|
+
return '<connection object at 0x{0:x}; closed: {1:}>'.format(
|
|
36
|
+
id(self), self.is_closed
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# Context manager integrations.
|
|
40
|
+
def __enter__(self):
|
|
41
|
+
return self
|
|
42
|
+
|
|
43
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
44
|
+
self.close()
|
|
45
|
+
|
|
46
|
+
def _make_client(self):
|
|
47
|
+
"""
|
|
48
|
+
:return: a new Client instance.
|
|
49
|
+
"""
|
|
50
|
+
if self.dsn is not None:
|
|
51
|
+
return Client.from_url(self.dsn)
|
|
52
|
+
|
|
53
|
+
return Client(self.host, port=self.port,
|
|
54
|
+
user=self.user, password=self.password,
|
|
55
|
+
database=self.database, **self.connection_kwargs)
|
|
56
|
+
|
|
57
|
+
def close(self):
|
|
58
|
+
"""
|
|
59
|
+
Close the connection now. The connection will be unusable from this
|
|
60
|
+
point forward; an :data:`~clickhouse_driver.dbapi.Error` (or subclass)
|
|
61
|
+
exception will be raised if any operation is attempted with the
|
|
62
|
+
connection. The same applies to all cursor objects trying to use the
|
|
63
|
+
connection.
|
|
64
|
+
"""
|
|
65
|
+
for cursor in self.cursors:
|
|
66
|
+
cursor.close()
|
|
67
|
+
|
|
68
|
+
self.is_closed = True
|
|
69
|
+
|
|
70
|
+
def commit(self):
|
|
71
|
+
"""
|
|
72
|
+
Do nothing since ClickHouse has no transactions.
|
|
73
|
+
"""
|
|
74
|
+
pass
|
|
75
|
+
|
|
76
|
+
def rollback(self):
|
|
77
|
+
"""
|
|
78
|
+
Do nothing since ClickHouse has no transactions.
|
|
79
|
+
"""
|
|
80
|
+
pass
|
|
81
|
+
|
|
82
|
+
def cursor(self, cursor_factory=None):
|
|
83
|
+
"""
|
|
84
|
+
:param cursor_factory: Argument can be used to create non-standard
|
|
85
|
+
cursors.
|
|
86
|
+
:return: a new cursor object using the connection.
|
|
87
|
+
"""
|
|
88
|
+
if self.is_closed:
|
|
89
|
+
raise InterfaceError('connection already closed')
|
|
90
|
+
|
|
91
|
+
client = self._make_client()
|
|
92
|
+
if self._hosts is None:
|
|
93
|
+
self._hosts = client.connection.hosts
|
|
94
|
+
else:
|
|
95
|
+
client.connection.hosts = self._hosts
|
|
96
|
+
cursor_factory = cursor_factory or Cursor
|
|
97
|
+
cursor = cursor_factory(client, self)
|
|
98
|
+
self.cursors.append(cursor)
|
|
99
|
+
return cursor
|