pyexasol 2.3.2__tar.gz → 2.4.1__tar.gz
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.
- {pyexasol-2.3.2 → pyexasol-2.4.1}/PKG-INFO +3 -2
- {pyexasol-2.3.2 → pyexasol-2.4.1}/exasol/driver/websocket/_connection.py +14 -13
- {pyexasol-2.3.2 → pyexasol-2.4.1}/exasol/driver/websocket/_cursor.py +8 -7
- {pyexasol-2.3.2 → pyexasol-2.4.1}/exasol/driver/websocket/_errors.py +24 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/callback.py +6 -5
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/connection.py +133 -41
- pyexasol-2.4.1/pyexasol/database_versions.py +51 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/ext.py +10 -2
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/http_transport.py +84 -244
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/meta.py +10 -4
- pyexasol-2.4.1/pyexasol/query_builders/base_builder.py +51 -0
- pyexasol-2.4.1/pyexasol/query_builders/common_formattings.py +185 -0
- pyexasol-2.4.1/pyexasol/query_builders/csv/__init__.py +22 -0
- pyexasol-2.4.1/pyexasol/query_builders/csv/builders.py +261 -0
- pyexasol-2.4.1/pyexasol/query_builders/csv/clause_formatter.py +160 -0
- pyexasol-2.4.1/pyexasol/query_builders/parquet/__init__.py +9 -0
- pyexasol-2.4.1/pyexasol/query_builders/parquet/builders.py +128 -0
- pyexasol-2.4.1/pyexasol/query_builders/parquet/clause_formatter.py +34 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyproject.toml +7 -2
- {pyexasol-2.3.2 → pyexasol-2.4.1}/LICENSE.txt +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/README.md +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/exasol/driver/__init__.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/exasol/driver/websocket/__init__.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/exasol/driver/websocket/_protocols.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/exasol/driver/websocket/_types.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/exasol/driver/websocket/dbapi2.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/__init__.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/__main__.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/_metadata.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/_sql_splitter.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/constant.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/db2/__init__.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/exceptions.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/formatter.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/local_config.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/logger.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/mapper.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/py.typed +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/script_output.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/statement.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol/warnings.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol_utils/__init__.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol_utils/bench.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol_utils/bench_sql/prepare.sql +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol_utils/bench_sql/t1_group_by.sql +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol_utils/bench_sql/t2_local_join.sql +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol_utils/bench_sql/t3_global_join.sql +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol_utils/bench_sql/t4_sort.sql +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol_utils/docker_util.py +0 -0
- {pyexasol-2.3.2 → pyexasol-2.4.1}/pyexasol_utils/script_output.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyexasol
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.1
|
|
4
4
|
Summary: Exasol python driver with extra features
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE.txt
|
|
@@ -39,12 +39,13 @@ Requires-Dist: pproxy ; extra == "all"
|
|
|
39
39
|
Requires-Dist: pproxy ; extra == "examples"
|
|
40
40
|
Requires-Dist: pyarrow (>=21.0.0) ; extra == "all"
|
|
41
41
|
Requires-Dist: pyarrow (>=21.0.0) ; extra == "pyarrow"
|
|
42
|
+
Requires-Dist: pydantic (>=2.13.4,<3.0.0)
|
|
42
43
|
Requires-Dist: pytest-benchmark[histogram] (>=5.1.0,<6) ; extra == "performance"
|
|
43
44
|
Requires-Dist: python-rapidjson (>=1.21.0,<2.0.0) ; extra == "all"
|
|
44
45
|
Requires-Dist: python-rapidjson (>=1.21.0,<2.0.0) ; extra == "rapidjson"
|
|
45
46
|
Requires-Dist: ujson (>=5.10.0,<6.0.0) ; extra == "all"
|
|
46
47
|
Requires-Dist: ujson (>=5.10.0,<6.0.0) ; extra == "ujson"
|
|
47
|
-
Requires-Dist: websocket-client (>=1.0.1
|
|
48
|
+
Requires-Dist: websocket-client (>=1.0.1,<=1.9.0)
|
|
48
49
|
Project-URL: Changelog, https://exasol.github.io/pyexasol/master/changes/changelog.html
|
|
49
50
|
Project-URL: Documentation, https://github.com/exasol/pyexasol/
|
|
50
51
|
Project-URL: Homepage, https://www.exasol.com/
|
|
@@ -10,7 +10,10 @@ from functools import wraps
|
|
|
10
10
|
|
|
11
11
|
import pyexasol
|
|
12
12
|
from exasol.driver.websocket._cursor import Cursor as DefaultCursor
|
|
13
|
-
from exasol.driver.websocket._errors import
|
|
13
|
+
from exasol.driver.websocket._errors import (
|
|
14
|
+
InterfaceError,
|
|
15
|
+
translate_exception,
|
|
16
|
+
)
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
def _requires_connection(method):
|
|
@@ -18,13 +21,13 @@ def _requires_connection(method):
|
|
|
18
21
|
Decorator requires the object to have a working connection.
|
|
19
22
|
|
|
20
23
|
Raises:
|
|
21
|
-
|
|
24
|
+
InterfaceError if the connection object has no active connection.
|
|
22
25
|
"""
|
|
23
26
|
|
|
24
27
|
@wraps(method)
|
|
25
28
|
def wrapper(self, *args, **kwargs):
|
|
26
29
|
if not self._connection:
|
|
27
|
-
raise
|
|
30
|
+
raise InterfaceError("No active connection available")
|
|
28
31
|
return method(self, *args, **kwargs)
|
|
29
32
|
|
|
30
33
|
return wrapper
|
|
@@ -107,10 +110,8 @@ class Connection:
|
|
|
107
110
|
"""See also :py:meth: `Connection.connect`"""
|
|
108
111
|
try:
|
|
109
112
|
self._connection = pyexasol.connect(**self._options)
|
|
110
|
-
except pyexasol.exceptions.
|
|
111
|
-
raise
|
|
112
|
-
except Exception as ex:
|
|
113
|
-
raise Error() from ex
|
|
113
|
+
except pyexasol.exceptions.ExaError as ex:
|
|
114
|
+
raise translate_exception(ex) from ex
|
|
114
115
|
return self
|
|
115
116
|
|
|
116
117
|
@property
|
|
@@ -126,24 +127,24 @@ class Connection:
|
|
|
126
127
|
return
|
|
127
128
|
try:
|
|
128
129
|
connection_to_close.close()
|
|
129
|
-
except
|
|
130
|
-
raise
|
|
130
|
+
except pyexasol.exceptions.ExaError as ex:
|
|
131
|
+
raise translate_exception(ex) from ex
|
|
131
132
|
|
|
132
133
|
@_requires_connection
|
|
133
134
|
def commit(self):
|
|
134
135
|
"""See also :py:meth: `Connection.commit`"""
|
|
135
136
|
try:
|
|
136
137
|
self._connection.commit()
|
|
137
|
-
except
|
|
138
|
-
raise
|
|
138
|
+
except pyexasol.exceptions.ExaError as ex:
|
|
139
|
+
raise translate_exception(ex) from ex
|
|
139
140
|
|
|
140
141
|
@_requires_connection
|
|
141
142
|
def rollback(self):
|
|
142
143
|
"""See also :py:meth: `Connection.rollback`"""
|
|
143
144
|
try:
|
|
144
145
|
self._connection.rollback()
|
|
145
|
-
except
|
|
146
|
-
raise
|
|
146
|
+
except pyexasol.exceptions.ExaError as ex:
|
|
147
|
+
raise translate_exception(ex) from ex
|
|
147
148
|
|
|
148
149
|
@_requires_connection
|
|
149
150
|
def cursor(self):
|
|
@@ -16,8 +16,9 @@ from functools import wraps
|
|
|
16
16
|
|
|
17
17
|
import pyexasol.exceptions
|
|
18
18
|
from exasol.driver.websocket._errors import (
|
|
19
|
-
|
|
19
|
+
InterfaceError,
|
|
20
20
|
NotSupportedError,
|
|
21
|
+
translate_exception,
|
|
21
22
|
)
|
|
22
23
|
from exasol.driver.websocket._types import TypeCode
|
|
23
24
|
|
|
@@ -57,13 +58,13 @@ def _is_not_closed(method):
|
|
|
57
58
|
Mark a function to require an open connection.
|
|
58
59
|
|
|
59
60
|
Raises:
|
|
60
|
-
|
|
61
|
+
InterfaceError if the marked function is called without an open connection.
|
|
61
62
|
"""
|
|
62
63
|
|
|
63
64
|
@wraps(method)
|
|
64
65
|
def wrapper(self, *args, **kwargs):
|
|
65
66
|
if self._is_closed:
|
|
66
|
-
raise
|
|
67
|
+
raise InterfaceError(
|
|
67
68
|
f"Unable to execute operation <{method.__name__}>, because cursor was already closed."
|
|
68
69
|
)
|
|
69
70
|
return method(self, *args, **kwargs)
|
|
@@ -76,13 +77,13 @@ def _requires_result(method):
|
|
|
76
77
|
Decorator requires the object to have a result.
|
|
77
78
|
|
|
78
79
|
Raises:
|
|
79
|
-
|
|
80
|
+
InterfaceError if the cursor object has not produced a result yet.
|
|
80
81
|
"""
|
|
81
82
|
|
|
82
83
|
@wraps(method)
|
|
83
84
|
def wrapper(self, *args, **kwargs):
|
|
84
85
|
if not self._cursor:
|
|
85
|
-
raise
|
|
86
|
+
raise InterfaceError("No result has been produced.")
|
|
86
87
|
return method(self, *args, **kwargs)
|
|
87
88
|
|
|
88
89
|
return wrapper
|
|
@@ -227,7 +228,7 @@ class Cursor:
|
|
|
227
228
|
try:
|
|
228
229
|
self._cursor = connection.execute(operation)
|
|
229
230
|
except pyexasol.exceptions.ExaError as ex:
|
|
230
|
-
raise
|
|
231
|
+
raise translate_exception(ex) from ex
|
|
231
232
|
|
|
232
233
|
@staticmethod
|
|
233
234
|
def _adapt_to_requested_db_types(parameters, db_response):
|
|
@@ -299,7 +300,7 @@ class Cursor:
|
|
|
299
300
|
try:
|
|
300
301
|
self._cursor.execute_prepared(parameters)
|
|
301
302
|
except pyexasol.exceptions.ExaError as ex:
|
|
302
|
-
raise
|
|
303
|
+
raise translate_exception(ex) from ex
|
|
303
304
|
|
|
304
305
|
def _convert(self, rows):
|
|
305
306
|
if rows is None:
|
|
@@ -5,6 +5,14 @@ This module provides `PEP-249`_ compliant DBAPI exceptions.
|
|
|
5
5
|
.. _PEP-249-exceptions: https://peps.python.org/pep-0249/#exceptions
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
from pyexasol.exceptions import (
|
|
9
|
+
ExaCommunicationError,
|
|
10
|
+
ExaConcurrencyError,
|
|
11
|
+
ExaConnectionError,
|
|
12
|
+
ExaError,
|
|
13
|
+
ExaQueryError,
|
|
14
|
+
)
|
|
15
|
+
|
|
8
16
|
|
|
9
17
|
class Warning(Exception): # Required by spec. pylint: disable=W0622
|
|
10
18
|
"""
|
|
@@ -74,3 +82,19 @@ class NotSupportedError(DatabaseError):
|
|
|
74
82
|
by the database, e.g. requesting a .rollback() on a connection that does not
|
|
75
83
|
support transaction or has transactions turned off.
|
|
76
84
|
"""
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def translate_exception(exception: ExaError) -> Error:
|
|
88
|
+
"""Translate a PyExasol exception into a PEP-249 DBAPI exception.
|
|
89
|
+
|
|
90
|
+
The complete string representation is copied so the translated exception
|
|
91
|
+
remains useful even when the original cause is not inspected.
|
|
92
|
+
"""
|
|
93
|
+
exception_message = str(exception)
|
|
94
|
+
if isinstance(exception, ExaQueryError):
|
|
95
|
+
return ProgrammingError(exception_message)
|
|
96
|
+
elif isinstance(exception, (ExaConnectionError, ExaCommunicationError)):
|
|
97
|
+
return OperationalError(exception_message)
|
|
98
|
+
elif isinstance(exception, ExaConcurrencyError):
|
|
99
|
+
return InterfaceError(exception_message)
|
|
100
|
+
return DatabaseError(exception_message)
|
|
@@ -240,11 +240,12 @@ def import_from_parquet(
|
|
|
240
240
|
|
|
241
241
|
Args:
|
|
242
242
|
source: Local filepath specification(s) to process. Can be one of:
|
|
243
|
-
|
|
244
|
-
- pathlib.Path
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
243
|
+
|
|
244
|
+
- ``list[pathlib.Path]``: list of specific files
|
|
245
|
+
- ``pathlib.Path``: can be either a file or directory. If it is a directory,
|
|
246
|
+
all files matching the following pattern ``*.parquet`` will be processed.
|
|
247
|
+
- ``str``: representing a filepath which already contains a glob pattern
|
|
248
|
+
(e.g., ``/local_dir/*.parquet``)
|
|
248
249
|
**kwargs:
|
|
249
250
|
Custom params for :func:`pyarrow.parquet.ParquetFile.iter_batches`. This can be used
|
|
250
251
|
to specify what columns should be read and their preferred order.
|
|
@@ -34,7 +34,10 @@ from cryptography.hazmat.primitives.asymmetric import padding
|
|
|
34
34
|
from packaging.version import Version
|
|
35
35
|
|
|
36
36
|
from . import callback as cb
|
|
37
|
-
from . import
|
|
37
|
+
from . import (
|
|
38
|
+
constant,
|
|
39
|
+
database_versions,
|
|
40
|
+
)
|
|
38
41
|
from ._metadata import __version__
|
|
39
42
|
from ._sql_splitter import split_sql_script
|
|
40
43
|
from .exceptions import (
|
|
@@ -57,9 +60,14 @@ from .http_transport import (
|
|
|
57
60
|
ExaHttpThread,
|
|
58
61
|
ExaSQLExportThread,
|
|
59
62
|
ExaSQLImportThread,
|
|
63
|
+
ExaSQLThread,
|
|
60
64
|
)
|
|
61
65
|
from .logger import ExaLogger
|
|
62
66
|
from .meta import ExaMetaData
|
|
67
|
+
from .query_builders.csv.builders import (
|
|
68
|
+
ExportBuilder,
|
|
69
|
+
ImportBuilder,
|
|
70
|
+
)
|
|
63
71
|
from .script_output import ExaScriptOutputProcess
|
|
64
72
|
from .statement import ExaStatement
|
|
65
73
|
from .warnings import PyexasolWarning
|
|
@@ -492,7 +500,7 @@ class ExaConnection:
|
|
|
492
500
|
def export_to_file(
|
|
493
501
|
self,
|
|
494
502
|
dst,
|
|
495
|
-
query_or_table: str,
|
|
503
|
+
query_or_table: str | tuple[str, ...],
|
|
496
504
|
query_params: dict | None = None,
|
|
497
505
|
export_params: dict | None = None,
|
|
498
506
|
):
|
|
@@ -506,7 +514,13 @@ class ExaConnection:
|
|
|
506
514
|
dst:
|
|
507
515
|
Path to file or file-like object where data will be exported to.
|
|
508
516
|
query_or_table:
|
|
509
|
-
|
|
517
|
+
Source from which to export data. Can be one of:
|
|
518
|
+
|
|
519
|
+
- ``tuple[str, ...]``: fully qualified table identifier, such as
|
|
520
|
+
``("SCHEMA", "TABLE")``. Quoted table names must be fully qualified
|
|
521
|
+
using this tuple pattern.
|
|
522
|
+
- ``str``: if lacks non-trailing space, it is treated like a
|
|
523
|
+
table identifier. Otherwise, it is treated like a query.
|
|
510
524
|
query_params:
|
|
511
525
|
Values for SQL query placeholders.
|
|
512
526
|
export_params:
|
|
@@ -526,7 +540,7 @@ class ExaConnection:
|
|
|
526
540
|
|
|
527
541
|
def export_to_list(
|
|
528
542
|
self,
|
|
529
|
-
query_or_table: str,
|
|
543
|
+
query_or_table: str | tuple[str, ...],
|
|
530
544
|
query_params: dict | None = None,
|
|
531
545
|
export_params: dict | None = None,
|
|
532
546
|
) -> list:
|
|
@@ -535,7 +549,13 @@ class ExaConnection:
|
|
|
535
549
|
|
|
536
550
|
Args:
|
|
537
551
|
query_or_table:
|
|
538
|
-
|
|
552
|
+
Source from which to export data. Can be one of:
|
|
553
|
+
|
|
554
|
+
- ``tuple[str, ...]``: fully qualified table identifier, such as
|
|
555
|
+
``("SCHEMA", "TABLE")``. Quoted table names must be fully qualified
|
|
556
|
+
using this tuple pattern.
|
|
557
|
+
- ``str``: if lacks non-trailing space, it is treated like a
|
|
558
|
+
table identifier. Otherwise, it is treated like a query.
|
|
539
559
|
query_params:
|
|
540
560
|
Values for SQL query placeholders.
|
|
541
561
|
export_params:
|
|
@@ -559,7 +579,7 @@ class ExaConnection:
|
|
|
559
579
|
|
|
560
580
|
def export_to_pandas(
|
|
561
581
|
self,
|
|
562
|
-
query_or_table: str,
|
|
582
|
+
query_or_table: str | tuple[str, ...],
|
|
563
583
|
query_params: dict | None = None,
|
|
564
584
|
callback_params: dict | None = None,
|
|
565
585
|
export_params: dict | None = None,
|
|
@@ -569,7 +589,13 @@ class ExaConnection:
|
|
|
569
589
|
|
|
570
590
|
Args:
|
|
571
591
|
query_or_table:
|
|
572
|
-
|
|
592
|
+
Source from which to export data. Can be one of:
|
|
593
|
+
|
|
594
|
+
- ``tuple[str, ...]``: fully qualified table identifier, such as
|
|
595
|
+
``("SCHEMA", "TABLE")``. Quoted table names must be fully qualified
|
|
596
|
+
using this tuple pattern.
|
|
597
|
+
- ``str``: if lacks non-trailing space, it is treated like a
|
|
598
|
+
table identifier. Otherwise, it is treated like a query.
|
|
573
599
|
query_params:
|
|
574
600
|
Values for SQL query placeholders.
|
|
575
601
|
callback_params:
|
|
@@ -607,7 +633,7 @@ class ExaConnection:
|
|
|
607
633
|
def export_to_parquet(
|
|
608
634
|
self,
|
|
609
635
|
dst: Path | str,
|
|
610
|
-
query_or_table: str,
|
|
636
|
+
query_or_table: str | tuple[str, ...],
|
|
611
637
|
query_params: dict | None = None,
|
|
612
638
|
callback_params: dict | None = None,
|
|
613
639
|
export_params: dict | None = None,
|
|
@@ -639,7 +665,13 @@ class ExaConnection:
|
|
|
639
665
|
discussed on `Importing and Exporting Data <https://exasol.github.io/pyexasol/master/user_guide/exploring_features/import_and_export/index.html>`__.
|
|
640
666
|
|
|
641
667
|
query_or_table:
|
|
642
|
-
|
|
668
|
+
Source from which to export data. Can be one of:
|
|
669
|
+
|
|
670
|
+
- ``tuple[str, ...]``: fully qualified table identifier, such as
|
|
671
|
+
``("SCHEMA", "TABLE")``. Quoted table names must be fully qualified
|
|
672
|
+
using this tuple pattern.
|
|
673
|
+
- ``str``: if lacks non-trailing space, it is treated like a
|
|
674
|
+
table identifier. Otherwise, it is treated like a query.
|
|
643
675
|
query_params:
|
|
644
676
|
Values for SQL query placeholders.
|
|
645
677
|
callback_params:
|
|
@@ -681,7 +713,7 @@ class ExaConnection:
|
|
|
681
713
|
|
|
682
714
|
def export_to_polars(
|
|
683
715
|
self,
|
|
684
|
-
query_or_table: str,
|
|
716
|
+
query_or_table: str | tuple[str, ...],
|
|
685
717
|
query_params: dict | None = None,
|
|
686
718
|
callback_params: dict | None = None,
|
|
687
719
|
export_params: dict | None = None,
|
|
@@ -691,7 +723,13 @@ class ExaConnection:
|
|
|
691
723
|
|
|
692
724
|
Args:
|
|
693
725
|
query_or_table:
|
|
694
|
-
|
|
726
|
+
Source from which to export data. Can be one of:
|
|
727
|
+
|
|
728
|
+
- ``tuple[str, ...]``: fully qualified table identifier, such as
|
|
729
|
+
``("SCHEMA", "TABLE")``. Quoted table names must be fully qualified
|
|
730
|
+
using this tuple pattern.
|
|
731
|
+
- ``str``: if lacks non-trailing space, it is treated like a
|
|
732
|
+
table identifier. Otherwise, it is treated like a query.
|
|
695
733
|
query_params:
|
|
696
734
|
Values for SQL query placeholders.
|
|
697
735
|
callback_params:
|
|
@@ -726,7 +764,12 @@ class ExaConnection:
|
|
|
726
764
|
export_params,
|
|
727
765
|
)
|
|
728
766
|
|
|
729
|
-
def import_from_file(
|
|
767
|
+
def import_from_file(
|
|
768
|
+
self,
|
|
769
|
+
src,
|
|
770
|
+
table: str | tuple[str, ...],
|
|
771
|
+
import_params: dict | None = None,
|
|
772
|
+
):
|
|
730
773
|
"""
|
|
731
774
|
Import a large amount of data from a file or file-like object.
|
|
732
775
|
|
|
@@ -734,7 +777,11 @@ class ExaConnection:
|
|
|
734
777
|
src:
|
|
735
778
|
Source file or file-like object.
|
|
736
779
|
table:
|
|
737
|
-
Destination table for IMPORT.
|
|
780
|
+
Destination table for IMPORT. Can be one of:
|
|
781
|
+
|
|
782
|
+
- ``str``: table identifier.
|
|
783
|
+
- ``tuple[str, ...]``: schema-qualified table identifier, such as
|
|
784
|
+
``("SCHEMA", "TABLE")``.
|
|
738
785
|
import_params:
|
|
739
786
|
Custom parameters for IMPORT query.
|
|
740
787
|
|
|
@@ -746,7 +793,10 @@ class ExaConnection:
|
|
|
746
793
|
)
|
|
747
794
|
|
|
748
795
|
def import_from_iterable(
|
|
749
|
-
self,
|
|
796
|
+
self,
|
|
797
|
+
src: Iterable,
|
|
798
|
+
table: str | tuple[str, ...],
|
|
799
|
+
import_params: dict | None = None,
|
|
750
800
|
):
|
|
751
801
|
"""
|
|
752
802
|
Import a large amount of data from an ``iterable`` Python object.
|
|
@@ -756,7 +806,11 @@ class ExaConnection:
|
|
|
756
806
|
Source object implementing ``__iter__``.
|
|
757
807
|
Iterator must return tuples of values.
|
|
758
808
|
table:
|
|
759
|
-
Destination table for IMPORT.
|
|
809
|
+
Destination table for IMPORT. Can be one of:
|
|
810
|
+
|
|
811
|
+
- ``str``: table identifier.
|
|
812
|
+
- ``tuple[str, ...]``: schema-qualified table identifier, such as
|
|
813
|
+
``("SCHEMA", "TABLE")``.
|
|
760
814
|
import_params:
|
|
761
815
|
Custom parameters for IMPORT query.
|
|
762
816
|
"""
|
|
@@ -767,7 +821,7 @@ class ExaConnection:
|
|
|
767
821
|
def import_from_pandas(
|
|
768
822
|
self,
|
|
769
823
|
src: "pandas.DataFrame",
|
|
770
|
-
table: str,
|
|
824
|
+
table: str | tuple[str, ...],
|
|
771
825
|
callback_params: dict | None = None,
|
|
772
826
|
import_params: dict | None = None,
|
|
773
827
|
):
|
|
@@ -778,7 +832,11 @@ class ExaConnection:
|
|
|
778
832
|
src:
|
|
779
833
|
Source :class:`pandas.DataFrame` instance.
|
|
780
834
|
table:
|
|
781
|
-
Destination table for IMPORT.
|
|
835
|
+
Destination table for IMPORT. Can be one of:
|
|
836
|
+
|
|
837
|
+
- ``str``: table identifier.
|
|
838
|
+
- ``tuple[str, ...]``: schema-qualified table identifier, such as
|
|
839
|
+
``("SCHEMA", "TABLE")``.
|
|
782
840
|
callback_params:
|
|
783
841
|
Dictionary with additional parameters for callback function
|
|
784
842
|
`pandas.DataFrame.to_csv <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html>`__.
|
|
@@ -792,7 +850,7 @@ class ExaConnection:
|
|
|
792
850
|
def import_from_polars(
|
|
793
851
|
self,
|
|
794
852
|
src: Union["polars.LazyFrame", "polars.DataFrame"],
|
|
795
|
-
table: str,
|
|
853
|
+
table: str | tuple[str, ...],
|
|
796
854
|
callback_params: dict | None = None,
|
|
797
855
|
import_params: dict | None = None,
|
|
798
856
|
):
|
|
@@ -803,7 +861,11 @@ class ExaConnection:
|
|
|
803
861
|
src:
|
|
804
862
|
Source :class:`polars.DataFrame` or :class:`polars.LazyFrame` instance.
|
|
805
863
|
table:
|
|
806
|
-
Destination table for IMPORT.
|
|
864
|
+
Destination table for IMPORT. Can be one of:
|
|
865
|
+
|
|
866
|
+
- ``str``: table identifier.
|
|
867
|
+
- ``tuple[str, ...]``: schema-qualified table identifier, such as
|
|
868
|
+
``("SCHEMA", "TABLE")``.
|
|
807
869
|
callback_params:
|
|
808
870
|
Dictionary with additional parameters for callback function
|
|
809
871
|
`polars.DataFrame.write_csv <https://docs.pola.rs/api/python/stable/reference/api/polars.DataFrame.write_csv.html>`__.
|
|
@@ -817,22 +879,27 @@ class ExaConnection:
|
|
|
817
879
|
def import_from_parquet(
|
|
818
880
|
self,
|
|
819
881
|
source: list[Path] | Path | str,
|
|
820
|
-
table: str,
|
|
882
|
+
table: str | tuple[str, ...],
|
|
821
883
|
callback_params: dict | None = None,
|
|
822
884
|
import_params: dict | None = None,
|
|
823
885
|
):
|
|
824
886
|
"""
|
|
825
|
-
Import a large amount of data from
|
|
887
|
+
Import a large amount of data from local parquet file(s).
|
|
826
888
|
|
|
827
889
|
Args:
|
|
828
890
|
source: Local filepath specification(s) to process. Can be one of:
|
|
829
|
-
|
|
830
|
-
- pathlib.Path
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
891
|
+
|
|
892
|
+
- ``list[pathlib.Path]``: list of specific files
|
|
893
|
+
- ``pathlib.Path``: can be either a file or directory. If it's a directory,
|
|
894
|
+
all files matching this pattern ``*.parquet`` will be processed.
|
|
895
|
+
- ``str``: representing a filepath which already contains a glob pattern
|
|
896
|
+
(e.g., ``/local_dir/*.parquet``)
|
|
834
897
|
table:
|
|
835
|
-
Destination table for IMPORT.
|
|
898
|
+
Destination table for IMPORT. Can be one of:
|
|
899
|
+
|
|
900
|
+
- ``str``: table identifier.
|
|
901
|
+
- ``tuple[str, ...]``: schema-qualified table identifier, such as
|
|
902
|
+
``("SCHEMA", "TABLE")``.
|
|
836
903
|
callback_params:
|
|
837
904
|
Dict with additional parameters for callback function
|
|
838
905
|
`parquet.ParquetFile.iter_batches <https://arrow.apache.org/docs/python/generated/pyarrow.parquet.ParquetFile.html#pyarrow.parquet.ParquetFile.iter_batches>`__.
|
|
@@ -847,7 +914,7 @@ class ExaConnection:
|
|
|
847
914
|
self,
|
|
848
915
|
callback: Callable,
|
|
849
916
|
dst,
|
|
850
|
-
query_or_table: str,
|
|
917
|
+
query_or_table: str | tuple[str, ...],
|
|
851
918
|
query_params: dict | None = None,
|
|
852
919
|
callback_params: dict | None = None,
|
|
853
920
|
export_params: dict | None = None,
|
|
@@ -861,7 +928,13 @@ class ExaConnection:
|
|
|
861
928
|
dst:
|
|
862
929
|
(optional) Path to file or file-like object where data will be exported to.
|
|
863
930
|
query_or_table:
|
|
864
|
-
|
|
931
|
+
Source from which to export data. Can be one of:
|
|
932
|
+
|
|
933
|
+
- ``tuple[str, ...]``: fully qualified table identifier, such as
|
|
934
|
+
``("SCHEMA", "TABLE")``. Quoted table names must be fully qualified
|
|
935
|
+
using this tuple pattern.
|
|
936
|
+
- ``str``: if lacks non-trailing space, it is treated like a
|
|
937
|
+
table identifier. Otherwise, it is treated like a query.
|
|
865
938
|
query_params:
|
|
866
939
|
Values for SQL query placeholders.
|
|
867
940
|
callback_params:
|
|
@@ -874,6 +947,7 @@ class ExaConnection:
|
|
|
874
947
|
|
|
875
948
|
Raises:
|
|
876
949
|
TypeError: callback argument is not Callable.
|
|
950
|
+
pydantic.ValidationError: Invalid values from ``export_params``.
|
|
877
951
|
ExaExportError: one or more exceptions occurred when executing the
|
|
878
952
|
callback function.
|
|
879
953
|
|
|
@@ -899,13 +973,19 @@ class ExaConnection:
|
|
|
899
973
|
if export_params is None:
|
|
900
974
|
export_params = {}
|
|
901
975
|
|
|
902
|
-
if query_params is not None:
|
|
976
|
+
if query_params is not None and isinstance(query_or_table, str):
|
|
903
977
|
query_or_table = self.format.format(query_or_table, **query_params)
|
|
904
978
|
|
|
905
979
|
compression = (
|
|
906
980
|
False if ("format" in export_params) else self.options["compression"]
|
|
907
981
|
)
|
|
908
982
|
|
|
983
|
+
export_builder = ExportBuilder(
|
|
984
|
+
compression=compression,
|
|
985
|
+
query_or_table=query_or_table,
|
|
986
|
+
**export_params,
|
|
987
|
+
)
|
|
988
|
+
|
|
909
989
|
# Set when either worker finishes, successfully or exceptionally. It
|
|
910
990
|
# wakes the coordinator but does not terminate the other worker.
|
|
911
991
|
worker_finished_event = threading.Event()
|
|
@@ -916,12 +996,11 @@ class ExaConnection:
|
|
|
916
996
|
encryption=self.options["encryption"],
|
|
917
997
|
worker_finished_event=worker_finished_event,
|
|
918
998
|
)
|
|
919
|
-
sql_thread =
|
|
999
|
+
sql_thread = ExaSQLThread(
|
|
920
1000
|
connection=self,
|
|
921
1001
|
compression=compression,
|
|
922
|
-
query_or_table=query_or_table,
|
|
923
|
-
export_params=export_params,
|
|
924
1002
|
worker_finished_event=worker_finished_event,
|
|
1003
|
+
query_builder=export_builder,
|
|
925
1004
|
)
|
|
926
1005
|
|
|
927
1006
|
try:
|
|
@@ -966,7 +1045,7 @@ class ExaConnection:
|
|
|
966
1045
|
self,
|
|
967
1046
|
callback: Callable,
|
|
968
1047
|
src,
|
|
969
|
-
table: str,
|
|
1048
|
+
table: str | tuple[str, ...],
|
|
970
1049
|
callback_params: dict | None = None,
|
|
971
1050
|
import_params: dict | None = None,
|
|
972
1051
|
):
|
|
@@ -979,7 +1058,11 @@ class ExaConnection:
|
|
|
979
1058
|
src:
|
|
980
1059
|
Source for the callback function.
|
|
981
1060
|
table:
|
|
982
|
-
Destination table for IMPORT.
|
|
1061
|
+
Destination table for IMPORT. Can be one of:
|
|
1062
|
+
|
|
1063
|
+
- ``str``: table identifier.
|
|
1064
|
+
- ``tuple[str, ...]``: schema-qualified table identifier, such as
|
|
1065
|
+
``("SCHEMA", "TABLE")``.
|
|
983
1066
|
callback_params:
|
|
984
1067
|
Dictionary with additional parameters for callback function.
|
|
985
1068
|
import_params:
|
|
@@ -987,6 +1070,7 @@ class ExaConnection:
|
|
|
987
1070
|
|
|
988
1071
|
Raises:
|
|
989
1072
|
TypeError: callback argument is not Callable.
|
|
1073
|
+
pydantic.ValidationError: Invalid values from ``import_params``.
|
|
990
1074
|
"""
|
|
991
1075
|
if not callable(callback):
|
|
992
1076
|
raise TypeError(
|
|
@@ -1003,6 +1087,12 @@ class ExaConnection:
|
|
|
1003
1087
|
False if ("format" in import_params) else self.options["compression"]
|
|
1004
1088
|
)
|
|
1005
1089
|
|
|
1090
|
+
import_builder = ImportBuilder(
|
|
1091
|
+
compression=compression,
|
|
1092
|
+
table=table,
|
|
1093
|
+
**import_params,
|
|
1094
|
+
)
|
|
1095
|
+
|
|
1006
1096
|
# Set when either worker finishes, successfully or exceptionally. It
|
|
1007
1097
|
# wakes the coordinator but does not terminate the other worker.
|
|
1008
1098
|
worker_finished_event = threading.Event()
|
|
@@ -1013,12 +1103,11 @@ class ExaConnection:
|
|
|
1013
1103
|
encryption=self.options["encryption"],
|
|
1014
1104
|
worker_finished_event=worker_finished_event,
|
|
1015
1105
|
)
|
|
1016
|
-
sql_thread =
|
|
1106
|
+
sql_thread = ExaSQLThread(
|
|
1017
1107
|
connection=self,
|
|
1018
1108
|
compression=compression,
|
|
1019
|
-
table=table,
|
|
1020
|
-
import_params=import_params,
|
|
1021
1109
|
worker_finished_event=worker_finished_event,
|
|
1110
|
+
query_builder=import_builder,
|
|
1022
1111
|
)
|
|
1023
1112
|
|
|
1024
1113
|
try:
|
|
@@ -1168,7 +1257,7 @@ class ExaConnection:
|
|
|
1168
1257
|
and calls this "releaseVersion".
|
|
1169
1258
|
"""
|
|
1170
1259
|
if release_version := self.login_info.get("releaseVersion"):
|
|
1171
|
-
return
|
|
1260
|
+
return database_versions.parse(release_version)
|
|
1172
1261
|
return None
|
|
1173
1262
|
|
|
1174
1263
|
def last_statement(self) -> ExaStatement:
|
|
@@ -1605,9 +1694,12 @@ class ExaConnection:
|
|
|
1605
1694
|
result = []
|
|
1606
1695
|
|
|
1607
1696
|
dsn_re = re.compile(
|
|
1608
|
-
|
|
1697
|
+
# Hostname must not contain the ":" and "/" separators, otherwise a
|
|
1698
|
+
# misplaced fingerprint (e.g. localhost:8563/1234) is silently parsed
|
|
1699
|
+
# as part of the hostname instead of being rejected.
|
|
1700
|
+
r"^(?P<hostname_prefix>[^:/]+?)"
|
|
1609
1701
|
# Optional range (e.g. myxasol1..4.com)
|
|
1610
|
-
r"(?:(?P<range_start>\d+)\.\.(?P<range_end>\d+)(?P<hostname_suffix
|
|
1702
|
+
r"(?:(?P<range_start>\d+)\.\.(?P<range_end>\d+)(?P<hostname_suffix>[^:/]*?))?"
|
|
1611
1703
|
# Optional fingerprint (e.g. myexasol1..4.com/135a1d2dce102de866f58267521f4232153545a075dc85f8f7596f57e588a181)
|
|
1612
1704
|
r"(?:/(?P<fingerprint>[0-9A-Fa-f]+|nocertcheck))?"
|
|
1613
1705
|
# Optional port (e.g. myexasol1..4.com:8564)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Minimum Exasol database versions required for supported features."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
|
|
6
|
+
from packaging.version import Version
|
|
7
|
+
|
|
8
|
+
VERSION_PATTERN = re.compile(r"^\d+\.\d+\.\d+")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ExasolVersionFormatError(Exception):
|
|
12
|
+
"""Unsupported format of Exasol version."""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def parse(version: str) -> Version:
|
|
16
|
+
if m := VERSION_PATTERN.match(version):
|
|
17
|
+
return Version(m.group(0))
|
|
18
|
+
raise ExasolVersionFormatError(f'Unsupported Exasol version "{version}".')
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(frozen=True)
|
|
22
|
+
class DatabaseFeatureVersion:
|
|
23
|
+
"""Document a database feature's minimum supported Exasol version."""
|
|
24
|
+
|
|
25
|
+
version: Version
|
|
26
|
+
description: str
|
|
27
|
+
documentation_url: str
|
|
28
|
+
|
|
29
|
+
def is_supported_by(self, database_version: Version | None) -> bool:
|
|
30
|
+
"""Return whether the given database version supports this feature."""
|
|
31
|
+
return database_version is not None and database_version >= self.version
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
MIN_VERSION_FOR_TLS_PUBLIC_KEY = DatabaseFeatureVersion(
|
|
35
|
+
version=Version("8.32.0"),
|
|
36
|
+
description=(
|
|
37
|
+
"Exasol 8.32.0 introduced certificate verification for IMPORT and "
|
|
38
|
+
"EXPORT file connections, requiring the SHA-256 fingerprint of the "
|
|
39
|
+
"server certificate's public key when encryption is enabled."
|
|
40
|
+
),
|
|
41
|
+
documentation_url="https://docs.exasol.com/db/latest/changelogs/21747.htm",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
MIN_VERSION_FOR_NATIVE_PARQUET_IMPORT = DatabaseFeatureVersion(
|
|
45
|
+
version=Version("2026.1.0"),
|
|
46
|
+
description=(
|
|
47
|
+
"Exasol 2026.1.0 introduced full native Parquet import support, "
|
|
48
|
+
"including imports from local files."
|
|
49
|
+
),
|
|
50
|
+
documentation_url="https://docs.exasol.com/db/latest/release_notes_db/2026.1.0.htm",
|
|
51
|
+
)
|