snowflake-connector-python 5.2.0__cp315-cp315-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.
- snowflake/connector/__init__.py +148 -0
- snowflake/connector/_common/__init__.py +0 -0
- snowflake/connector/_common/extras.py +134 -0
- snowflake/connector/_common/telemetry.py +221 -0
- snowflake/connector/_common/wif_util.py +92 -0
- snowflake/connector/_core/sf_core_python.cp315-win_amd64.pyd +0 -0
- snowflake/connector/_core/sf_core_python.pyi +79 -0
- snowflake/connector/_internal/__init__.py +6 -0
- snowflake/connector/_internal/_private_key_helper.py +31 -0
- snowflake/connector/_internal/api_client/__init__.py +93 -0
- snowflake/connector/_internal/api_client/bridge.py +41 -0
- snowflake/connector/_internal/api_client/client_api.py +976 -0
- snowflake/connector/_internal/arrow.py +47 -0
- snowflake/connector/_internal/arrow_context.py +240 -0
- snowflake/connector/_internal/arrow_stream_async.py +266 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp311-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp312-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp313-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp314-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp314t-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp315-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.pyi +42 -0
- snowflake/connector/_internal/arrow_stream_utils.py +171 -0
- snowflake/connector/_internal/authenticator_type.py +53 -0
- snowflake/connector/_internal/backward_compatibility.py +245 -0
- snowflake/connector/_internal/binding_converters.py +741 -0
- snowflake/connector/_internal/config_utils.py +71 -0
- snowflake/connector/_internal/connection/__init__.py +39 -0
- snowflake/connector/_internal/connection/connection.py +616 -0
- snowflake/connector/_internal/connection/connection_types.py +13 -0
- snowflake/connector/_internal/connection/constants.py +25 -0
- snowflake/connector/_internal/connection/decorators.py +31 -0
- snowflake/connector/_internal/connection/freezable_proxy.py +104 -0
- snowflake/connector/_internal/connection/queries.py +10 -0
- snowflake/connector/_internal/connection_config_mixin.py +755 -0
- snowflake/connector/_internal/cursor/__init__.py +25 -0
- snowflake/connector/_internal/cursor/base.py +732 -0
- snowflake/connector/_internal/cursor/cursor_types.py +13 -0
- snowflake/connector/_internal/cursor/decorators.py +56 -0
- snowflake/connector/_internal/cursor/query_result.py +202 -0
- snowflake/connector/_internal/cursor/query_result_waiter.py +98 -0
- snowflake/connector/_internal/cursor/result_metadata.py +255 -0
- snowflake/connector/_internal/cursor/result_set_wrapper.py +66 -0
- snowflake/connector/_internal/decorators.py +539 -0
- snowflake/connector/_internal/error_kinds.py +111 -0
- snowflake/connector/_internal/errorcode.py +35 -0
- snowflake/connector/_internal/errorhandler.py +278 -0
- snowflake/connector/_internal/fips.py +28 -0
- snowflake/connector/_internal/logging/__init__.py +52 -0
- snowflake/connector/_internal/logging/config.py +134 -0
- snowflake/connector/_internal/logging/core_logger.py +218 -0
- snowflake/connector/_internal/logging/native_extension_logger.py +144 -0
- snowflake/connector/_internal/logout_config_mapping.py +187 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +57 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrowTableConverter.cpp +943 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrowTableConverter.hpp +63 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +18 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +118 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +116 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamIterator.cpp +323 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamIterator.hpp +133 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamTableIterator.cpp +275 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamTableIterator.hpp +168 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ConverterUtil.cpp +439 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ConverterUtil.hpp +30 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +48 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +76 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +90 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +63 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +62 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +29 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +41 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +65 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +54 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +79 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +52 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +117 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +54 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +34 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +33 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +18 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +39 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +326 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +138 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/time.cpp +65 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/arrow_stream_iterator.cpp +13278 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/arrow_stream_iterator.pyx +204 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +109 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +125 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1914 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +208 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +128 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +58 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +144 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +160 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +98 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +243 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +207 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +80 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +83 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +201 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +108 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +164 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +926 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +182 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc.c +3052 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3019 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3354 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +344 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +29305 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +381 -0
- snowflake/connector/_internal/nanoarrow_cpp/Logging/logging.cpp +108 -0
- snowflake/connector/_internal/nanoarrow_cpp/Logging/logging.hpp +47 -0
- snowflake/connector/_internal/nanoarrow_cpp/scripts/.clang-format +8 -0
- snowflake/connector/_internal/nanoarrow_cpp/scripts/format.sh +8 -0
- snowflake/connector/_internal/protobuf_gen/__init__.py +0 -0
- snowflake/connector/_internal/protobuf_gen/database_driver_v1_pb2.py +408 -0
- snowflake/connector/_internal/protobuf_gen/database_driver_v1_pb2.pyi +4487 -0
- snowflake/connector/_internal/protobuf_gen/database_driver_v1_services.py +2088 -0
- snowflake/connector/_internal/protobuf_gen/proto_exception.py +17 -0
- snowflake/connector/_internal/result_batch.py +150 -0
- snowflake/connector/_internal/snowflake_restful.py +222 -0
- snowflake/connector/_internal/snowpark_backcompat_helpers.py +31 -0
- snowflake/connector/_internal/sqlstate.py +11 -0
- snowflake/connector/_internal/statement_utils.py +207 -0
- snowflake/connector/_internal/text_utils.py +112 -0
- snowflake/connector/_internal/type_codes.py +139 -0
- snowflake/connector/_internal/utils.py +65 -0
- snowflake/connector/_internal/write_pandas_operation.py +657 -0
- snowflake/connector/aio/README.md +168 -0
- snowflake/connector/aio/__init__.py +37 -0
- snowflake/connector/aio/connection/__init__.py +17 -0
- snowflake/connector/aio/connection/_connection.py +506 -0
- snowflake/connector/aio/cursor/__init__.py +35 -0
- snowflake/connector/aio/cursor/_base.py +1034 -0
- snowflake/connector/aio/cursor/_dict_cursor.py +78 -0
- snowflake/connector/aio/cursor/_result_set_wrapper.py +35 -0
- snowflake/connector/aio/cursor/_snowflake_cursor.py +72 -0
- snowflake/connector/aio/pandas_tools.py +279 -0
- snowflake/connector/aio/result_batch.py +165 -0
- snowflake/connector/auth/__init__.py +0 -0
- snowflake/connector/auth/workload_identity.py +5 -0
- snowflake/connector/compat.py +22 -0
- snowflake/connector/config_manager.py +392 -0
- snowflake/connector/connection/__init__.py +30 -0
- snowflake/connector/connection/_connection.py +641 -0
- snowflake/connector/connection_config.py +517 -0
- snowflake/connector/constants.py +52 -0
- snowflake/connector/cursor/__init__.py +37 -0
- snowflake/connector/cursor/_base.py +1169 -0
- snowflake/connector/cursor/_chunked_download_reader.py +75 -0
- snowflake/connector/cursor/_dict_cursor.py +78 -0
- snowflake/connector/cursor/_result_set_wrapper.py +35 -0
- snowflake/connector/cursor/_snowflake_cursor.py +72 -0
- snowflake/connector/description.py +7 -0
- snowflake/connector/errors.py +492 -0
- snowflake/connector/network.py +71 -0
- snowflake/connector/pandas_tools.py +191 -0
- snowflake/connector/py.typed +0 -0
- snowflake/connector/result_batch.py +216 -0
- snowflake/connector/telemetry.py +40 -0
- snowflake/connector/time_util.py +11 -0
- snowflake/connector/types.py +134 -0
- snowflake/connector/util_text.py +3 -0
- snowflake/connector/version.py +23 -0
- snowflake_connector_python-5.2.0.dist-info/DELVEWHEEL +2 -0
- snowflake_connector_python-5.2.0.dist-info/METADATA +190 -0
- snowflake_connector_python-5.2.0.dist-info/RECORD +204 -0
- snowflake_connector_python-5.2.0.dist-info/WHEEL +4 -0
- snowflake_connector_python.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import io
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from .._internal.api_client.client_api import CHUNK_SIZE, core_driver
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from _typeshed import WriteableBuffer
|
|
12
|
+
|
|
13
|
+
from .._internal.protobuf_gen.database_driver_v1_pb2 import DownloadStreamHandle
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class _ChunkedDownloadReader(io.RawIOBase):
|
|
17
|
+
"""Lazily reads a stage file via the Begin/Chunk/Close RPCs.
|
|
18
|
+
|
|
19
|
+
Nothing beyond Begin fires until read; each ``read()`` pulls one chunk
|
|
20
|
+
via :func:`readinto`, so at most one chunk sits in memory. This holds for
|
|
21
|
+
iteration and for ``read(size)`` with a non-negative *size* — ``read(-1)``
|
|
22
|
+
/ ``readall()`` (the ``io.RawIOBase`` default for a full read) loops
|
|
23
|
+
``readinto`` to EOF and accumulates the whole file in memory, inherent to
|
|
24
|
+
a read-all. The session is released exactly once, on EOF, on error, or on
|
|
25
|
+
close (including via ``io.IOBase.__del__`` as a safety net) — whichever
|
|
26
|
+
happens first.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(self, download_handle: DownloadStreamHandle) -> None:
|
|
30
|
+
super().__init__()
|
|
31
|
+
self._download_handle = download_handle
|
|
32
|
+
self._pending = b""
|
|
33
|
+
self._eof = False
|
|
34
|
+
self._handle_released = False
|
|
35
|
+
|
|
36
|
+
def readable(self) -> bool:
|
|
37
|
+
return True
|
|
38
|
+
|
|
39
|
+
def readinto(self, b: WriteableBuffer) -> int:
|
|
40
|
+
# Loop rather than pull-once: a chunk with data=b"" and eof=False is a
|
|
41
|
+
# legal (if unusual) core response, and returning 0 here would make
|
|
42
|
+
# io.RawIOBase.readall() treat it as EOF and silently truncate.
|
|
43
|
+
while not self._pending and not self._eof:
|
|
44
|
+
self._pull_chunk()
|
|
45
|
+
view = memoryview(b)
|
|
46
|
+
n = min(len(view), len(self._pending))
|
|
47
|
+
view[:n] = self._pending[:n]
|
|
48
|
+
self._pending = self._pending[n:]
|
|
49
|
+
return n
|
|
50
|
+
|
|
51
|
+
def _pull_chunk(self) -> None:
|
|
52
|
+
"""Fetch one core-side chunk into ``_pending``; release on EOF/error."""
|
|
53
|
+
try:
|
|
54
|
+
response = core_driver.download_stream_chunk(self._download_handle, CHUNK_SIZE)
|
|
55
|
+
except BaseException:
|
|
56
|
+
self._release_handle()
|
|
57
|
+
raise
|
|
58
|
+
self._pending = response.data
|
|
59
|
+
if response.eof:
|
|
60
|
+
self._eof = True
|
|
61
|
+
self._release_handle()
|
|
62
|
+
|
|
63
|
+
def _release_handle(self) -> None:
|
|
64
|
+
if self._handle_released:
|
|
65
|
+
return
|
|
66
|
+
self._handle_released = True
|
|
67
|
+
core_driver.download_stream_close(self._download_handle)
|
|
68
|
+
|
|
69
|
+
def close(self) -> None:
|
|
70
|
+
if self.closed:
|
|
71
|
+
return
|
|
72
|
+
try:
|
|
73
|
+
self._release_handle()
|
|
74
|
+
finally:
|
|
75
|
+
super().close()
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Concrete DictCursor — returns dict rows."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import cast
|
|
6
|
+
|
|
7
|
+
from .._internal.cursor import DictRow
|
|
8
|
+
from .._internal.errorhandler import simplified_error_handling
|
|
9
|
+
from ._base import SnowflakeCursorBase
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DictCursor(SnowflakeCursorBase):
|
|
13
|
+
"""Cursor returning results as dictionaries with column names as keys.
|
|
14
|
+
|
|
15
|
+
Usage::
|
|
16
|
+
|
|
17
|
+
with connection.cursor(DictCursor) as cur:
|
|
18
|
+
cur.execute("SELECT 1 AS id, 'hello' AS name")
|
|
19
|
+
row = cur.fetchone()
|
|
20
|
+
# row == {"ID": 1, "NAME": "hello"}
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def _use_dict_result(self) -> bool:
|
|
25
|
+
return True
|
|
26
|
+
|
|
27
|
+
@simplified_error_handling
|
|
28
|
+
def fetchone(self) -> DictRow | None:
|
|
29
|
+
"""
|
|
30
|
+
Fetch the next row of a query result set as a dictionary.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
dict: Next row as a dictionary with column names as keys,
|
|
34
|
+
or None when no more data is available
|
|
35
|
+
"""
|
|
36
|
+
return cast(DictRow | None, self._fetchone())
|
|
37
|
+
|
|
38
|
+
@simplified_error_handling
|
|
39
|
+
def fetchmany(self, size: int | None = None) -> list[DictRow]:
|
|
40
|
+
"""
|
|
41
|
+
Fetch the next set of rows as dictionaries.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
size (int): Number of rows to fetch (defaults to arraysize)
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
list[dict]: List of rows as dictionaries
|
|
48
|
+
"""
|
|
49
|
+
return super().fetchmany(size)
|
|
50
|
+
|
|
51
|
+
def fetchall(self) -> list[DictRow]:
|
|
52
|
+
"""
|
|
53
|
+
Fetch all (remaining) rows as dictionaries.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
list[dict]: List of all remaining rows as dictionaries
|
|
57
|
+
"""
|
|
58
|
+
return super().fetchall()
|
|
59
|
+
|
|
60
|
+
def __next__(self) -> DictRow:
|
|
61
|
+
"""
|
|
62
|
+
Fetch the next row from the currently executed statement as a dictionary.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
dict: Next row
|
|
66
|
+
|
|
67
|
+
Raises:
|
|
68
|
+
StopIteration: When no more rows are available
|
|
69
|
+
"""
|
|
70
|
+
return cast(DictRow, super().__next__())
|
|
71
|
+
|
|
72
|
+
def next(self) -> DictRow:
|
|
73
|
+
"""Python 2 compatibility alias for ``__next__``. Returns a dictionary row.
|
|
74
|
+
|
|
75
|
+
Raises:
|
|
76
|
+
StopIteration: When no more rows are available
|
|
77
|
+
"""
|
|
78
|
+
return self.__next__()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .._internal.api_client.client_api import core_driver
|
|
4
|
+
from .._internal.cursor.result_set_wrapper import ResultSetWrapperBase
|
|
5
|
+
from .._internal.protobuf_gen.database_driver_v1_pb2 import (
|
|
6
|
+
ResultSetGetChunksResponse,
|
|
7
|
+
)
|
|
8
|
+
from .._internal.statement_utils import get_stream_ptr
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class _ResultSetWrapper(ResultSetWrapperBase):
|
|
12
|
+
"""Sync result-set handle owner."""
|
|
13
|
+
|
|
14
|
+
def get_arrow_stream_ptr(self) -> int:
|
|
15
|
+
"""Fetch the Arrow stream and return the raw C pointer.
|
|
16
|
+
|
|
17
|
+
Each call builds a fresh stream from the stored result set data.
|
|
18
|
+
|
|
19
|
+
Raises:
|
|
20
|
+
ProgrammingError: If no handle is held.
|
|
21
|
+
"""
|
|
22
|
+
handle = self._require_handle()
|
|
23
|
+
response = core_driver.result_set_get_stream(result_set_handle=handle)
|
|
24
|
+
return get_stream_ptr(response)
|
|
25
|
+
|
|
26
|
+
def get_chunks(self) -> ResultSetGetChunksResponse | None:
|
|
27
|
+
"""Call ``result_set_get_chunks`` on the held handle, or return ``None``.
|
|
28
|
+
|
|
29
|
+
Safe to call multiple times and independently of :meth:`get_arrow_stream_ptr` —
|
|
30
|
+
the core layer re-fetches chunk metadata from Snowflake if the cached copy
|
|
31
|
+
was already consumed.
|
|
32
|
+
"""
|
|
33
|
+
if self._handle is None:
|
|
34
|
+
return None
|
|
35
|
+
return core_driver.result_set_get_chunks(result_set_handle=self._handle)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""Concrete SnowflakeCursor — returns tuple rows."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import cast
|
|
6
|
+
|
|
7
|
+
from .._internal.cursor import Row
|
|
8
|
+
from .._internal.errorhandler import simplified_error_handling
|
|
9
|
+
from ._base import SnowflakeCursorBase
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SnowflakeCursor(SnowflakeCursorBase):
|
|
13
|
+
"""Cursor returning results as tuples (default).
|
|
14
|
+
|
|
15
|
+
This is the standard cursor returned by ``connection.cursor()``.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def _use_dict_result(self) -> bool:
|
|
20
|
+
return False
|
|
21
|
+
|
|
22
|
+
@simplified_error_handling
|
|
23
|
+
def fetchone(self) -> Row | None:
|
|
24
|
+
"""
|
|
25
|
+
Fetch the next row of a query result set.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
tuple: Next row, or None when no more data is available
|
|
29
|
+
"""
|
|
30
|
+
return cast(Row | None, self._fetchone())
|
|
31
|
+
|
|
32
|
+
@simplified_error_handling
|
|
33
|
+
def fetchmany(self, size: int | None = None) -> list[Row]:
|
|
34
|
+
"""
|
|
35
|
+
Fetch the next set of rows of a query result.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
size (int): Number of rows to fetch (defaults to arraysize)
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
list[tuple]: List of rows as tuples
|
|
42
|
+
"""
|
|
43
|
+
return super().fetchmany(size)
|
|
44
|
+
|
|
45
|
+
def fetchall(self) -> list[Row]:
|
|
46
|
+
"""
|
|
47
|
+
Fetch all (remaining) rows of a query result.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
list[tuple]: List of all remaining rows as tuples
|
|
51
|
+
"""
|
|
52
|
+
return super().fetchall()
|
|
53
|
+
|
|
54
|
+
def __next__(self) -> Row:
|
|
55
|
+
"""
|
|
56
|
+
Fetch the next row from the currently executed statement.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
tuple: Next row
|
|
60
|
+
|
|
61
|
+
Raises:
|
|
62
|
+
StopIteration: When no more rows are available
|
|
63
|
+
"""
|
|
64
|
+
return cast(Row, super().__next__())
|
|
65
|
+
|
|
66
|
+
def next(self) -> Row:
|
|
67
|
+
"""Python 2 compatibility alias for ``__next__``. Returns a tuple row.
|
|
68
|
+
|
|
69
|
+
Raises:
|
|
70
|
+
StopIteration: When no more rows are available
|
|
71
|
+
"""
|
|
72
|
+
return self.__next__()
|