snowflake-connector-python 3.16.0__cp313-cp313-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.
Files changed (246) hide show
  1. snowflake/connector/__init__.py +96 -0
  2. snowflake/connector/_query_context_cache.py +276 -0
  3. snowflake/connector/_sql_util.py +48 -0
  4. snowflake/connector/_utils.py +70 -0
  5. snowflake/connector/arrow_context.py +203 -0
  6. snowflake/connector/auth/__init__.py +53 -0
  7. snowflake/connector/auth/_auth.py +586 -0
  8. snowflake/connector/auth/_http_server.py +220 -0
  9. snowflake/connector/auth/_oauth_base.py +400 -0
  10. snowflake/connector/auth/by_plugin.py +219 -0
  11. snowflake/connector/auth/default.py +36 -0
  12. snowflake/connector/auth/idtoken.py +72 -0
  13. snowflake/connector/auth/keypair.py +222 -0
  14. snowflake/connector/auth/no_auth.py +39 -0
  15. snowflake/connector/auth/oauth.py +49 -0
  16. snowflake/connector/auth/oauth_code.py +479 -0
  17. snowflake/connector/auth/oauth_credentials.py +66 -0
  18. snowflake/connector/auth/okta.py +335 -0
  19. snowflake/connector/auth/pat.py +39 -0
  20. snowflake/connector/auth/usrpwdmfa.py +69 -0
  21. snowflake/connector/auth/webbrowser.py +502 -0
  22. snowflake/connector/auth/workload_identity.py +94 -0
  23. snowflake/connector/azure_storage_client.py +276 -0
  24. snowflake/connector/backoff_policies.py +141 -0
  25. snowflake/connector/bind_upload_agent.py +89 -0
  26. snowflake/connector/cache.py +696 -0
  27. snowflake/connector/compat.py +127 -0
  28. snowflake/connector/config_manager.py +496 -0
  29. snowflake/connector/connection.py +2273 -0
  30. snowflake/connector/connection_diagnostic.py +776 -0
  31. snowflake/connector/constants.py +442 -0
  32. snowflake/connector/converter.py +785 -0
  33. snowflake/connector/converter_issue23517.py +87 -0
  34. snowflake/connector/converter_null.py +14 -0
  35. snowflake/connector/converter_snowsql.py +205 -0
  36. snowflake/connector/cursor.py +1951 -0
  37. snowflake/connector/dbapi.py +53 -0
  38. snowflake/connector/description.py +19 -0
  39. snowflake/connector/direct_file_operation_utils.py +88 -0
  40. snowflake/connector/encryption_util.py +220 -0
  41. snowflake/connector/errorcode.py +91 -0
  42. snowflake/connector/errors.py +615 -0
  43. snowflake/connector/externals_utils/__init__.py +0 -0
  44. snowflake/connector/externals_utils/externals_setup.py +27 -0
  45. snowflake/connector/feature.py +4 -0
  46. snowflake/connector/file_compression_type.py +118 -0
  47. snowflake/connector/file_lock.py +72 -0
  48. snowflake/connector/file_transfer_agent.py +1215 -0
  49. snowflake/connector/file_util.py +153 -0
  50. snowflake/connector/gcs_storage_client.py +474 -0
  51. snowflake/connector/gzip_decoder.py +85 -0
  52. snowflake/connector/local_storage_client.py +90 -0
  53. snowflake/connector/log_configuration.py +60 -0
  54. snowflake/connector/logging_utils/__init__.py +0 -0
  55. snowflake/connector/logging_utils/filters.py +72 -0
  56. snowflake/connector/nanoarrow_arrow_iterator.cp313-win_amd64.pyd +0 -0
  57. snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +60 -0
  58. snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
  59. snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +19 -0
  60. snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
  61. snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
  62. snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
  63. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.cpp +557 -0
  64. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.hpp +98 -0
  65. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +125 -0
  66. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +115 -0
  67. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.cpp +1005 -0
  68. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.hpp +127 -0
  69. snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +47 -0
  70. snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
  71. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +83 -0
  72. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
  73. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +97 -0
  74. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +72 -0
  75. snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +73 -0
  76. snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
  77. snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +30 -0
  78. snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
  79. snowflake/connector/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
  80. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
  81. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +45 -0
  82. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +71 -0
  83. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +56 -0
  84. snowflake/connector/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
  85. snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +75 -0
  86. snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
  87. snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +46 -0
  88. snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
  89. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
  90. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +95 -0
  91. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +57 -0
  92. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +36 -0
  93. snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +34 -0
  94. snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
  95. snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +19 -0
  96. snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
  97. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +36 -0
  98. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
  99. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +346 -0
  100. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +145 -0
  101. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
  102. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.cpp +65 -0
  103. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
  104. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +101 -0
  105. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +127 -0
  106. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
  107. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1908 -0
  108. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +215 -0
  109. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +125 -0
  110. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
  111. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +55 -0
  112. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +148 -0
  113. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
  114. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
  115. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
  116. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +162 -0
  117. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +97 -0
  118. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +239 -0
  119. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
  120. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +210 -0
  121. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +84 -0
  122. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +84 -0
  123. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
  124. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
  125. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +206 -0
  126. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +118 -0
  127. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
  128. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
  129. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
  130. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
  131. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
  132. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +162 -0
  133. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +898 -0
  134. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +190 -0
  135. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
  136. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
  137. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc.c +3204 -0
  138. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3217 -0
  139. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3618 -0
  140. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +379 -0
  141. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_arrow_iterator.pyx +256 -0
  142. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.c +512 -0
  143. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.h +350 -0
  144. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +33273 -0
  145. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +397 -0
  146. snowflake/connector/nanoarrow_cpp/Logging/logging.cpp +100 -0
  147. snowflake/connector/nanoarrow_cpp/Logging/logging.hpp +49 -0
  148. snowflake/connector/network.py +1297 -0
  149. snowflake/connector/ocsp_asn1crypto.py +447 -0
  150. snowflake/connector/ocsp_snowflake.py +1883 -0
  151. snowflake/connector/options.py +131 -0
  152. snowflake/connector/pandas_tools.py +732 -0
  153. snowflake/connector/proxy.py +43 -0
  154. snowflake/connector/py.typed +0 -0
  155. snowflake/connector/result_batch.py +786 -0
  156. snowflake/connector/result_set.py +319 -0
  157. snowflake/connector/s3_storage_client.py +605 -0
  158. snowflake/connector/secret_detector.py +181 -0
  159. snowflake/connector/sf_dirs.py +64 -0
  160. snowflake/connector/sfbinaryformat.py +35 -0
  161. snowflake/connector/sfdatetime.py +345 -0
  162. snowflake/connector/snow_logging.py +144 -0
  163. snowflake/connector/sqlstate.py +9 -0
  164. snowflake/connector/ssd_internal_keys.py +30 -0
  165. snowflake/connector/ssl_wrap_socket.py +134 -0
  166. snowflake/connector/storage_client.py +478 -0
  167. snowflake/connector/telemetry.py +249 -0
  168. snowflake/connector/telemetry_oob.py +543 -0
  169. snowflake/connector/test_util.py +30 -0
  170. snowflake/connector/time_util.py +159 -0
  171. snowflake/connector/token_cache.py +402 -0
  172. snowflake/connector/tool/__init__.py +0 -0
  173. snowflake/connector/tool/dump_certs.py +57 -0
  174. snowflake/connector/tool/dump_ocsp_response.py +139 -0
  175. snowflake/connector/tool/dump_ocsp_response_cache.py +194 -0
  176. snowflake/connector/tool/probe_connection.py +69 -0
  177. snowflake/connector/url_util.py +49 -0
  178. snowflake/connector/util_text.py +301 -0
  179. snowflake/connector/vendored/__init__.py +3 -0
  180. snowflake/connector/vendored/requests/LICENSE +175 -0
  181. snowflake/connector/vendored/requests/__init__.py +169 -0
  182. snowflake/connector/vendored/requests/__version__.py +14 -0
  183. snowflake/connector/vendored/requests/_internal_utils.py +50 -0
  184. snowflake/connector/vendored/requests/adapters.py +537 -0
  185. snowflake/connector/vendored/requests/api.py +157 -0
  186. snowflake/connector/vendored/requests/auth.py +315 -0
  187. snowflake/connector/vendored/requests/certs.py +17 -0
  188. snowflake/connector/vendored/requests/compat.py +79 -0
  189. snowflake/connector/vendored/requests/cookies.py +561 -0
  190. snowflake/connector/vendored/requests/exceptions.py +140 -0
  191. snowflake/connector/vendored/requests/help.py +134 -0
  192. snowflake/connector/vendored/requests/hooks.py +33 -0
  193. snowflake/connector/vendored/requests/models.py +1033 -0
  194. snowflake/connector/vendored/requests/sessions.py +833 -0
  195. snowflake/connector/vendored/requests/status_codes.py +128 -0
  196. snowflake/connector/vendored/requests/structures.py +99 -0
  197. snowflake/connector/vendored/requests/utils.py +1093 -0
  198. snowflake/connector/vendored/urllib3/LICENSE.txt +21 -0
  199. snowflake/connector/vendored/urllib3/__init__.py +85 -0
  200. snowflake/connector/vendored/urllib3/_collections.py +355 -0
  201. snowflake/connector/vendored/urllib3/_version.py +2 -0
  202. snowflake/connector/vendored/urllib3/connection.py +572 -0
  203. snowflake/connector/vendored/urllib3/connectionpool.py +1137 -0
  204. snowflake/connector/vendored/urllib3/contrib/__init__.py +0 -0
  205. snowflake/connector/vendored/urllib3/contrib/_appengine_environ.py +36 -0
  206. snowflake/connector/vendored/urllib3/contrib/_securetransport/__init__.py +0 -0
  207. snowflake/connector/vendored/urllib3/contrib/_securetransport/bindings.py +519 -0
  208. snowflake/connector/vendored/urllib3/contrib/_securetransport/low_level.py +397 -0
  209. snowflake/connector/vendored/urllib3/contrib/appengine.py +314 -0
  210. snowflake/connector/vendored/urllib3/contrib/ntlmpool.py +130 -0
  211. snowflake/connector/vendored/urllib3/contrib/pyopenssl.py +509 -0
  212. snowflake/connector/vendored/urllib3/contrib/securetransport.py +920 -0
  213. snowflake/connector/vendored/urllib3/contrib/socks.py +216 -0
  214. snowflake/connector/vendored/urllib3/exceptions.py +323 -0
  215. snowflake/connector/vendored/urllib3/fields.py +274 -0
  216. snowflake/connector/vendored/urllib3/filepost.py +98 -0
  217. snowflake/connector/vendored/urllib3/packages/__init__.py +0 -0
  218. snowflake/connector/vendored/urllib3/packages/backports/__init__.py +0 -0
  219. snowflake/connector/vendored/urllib3/packages/backports/makefile.py +51 -0
  220. snowflake/connector/vendored/urllib3/packages/backports/weakref_finalize.py +155 -0
  221. snowflake/connector/vendored/urllib3/packages/six.py +1076 -0
  222. snowflake/connector/vendored/urllib3/poolmanager.py +540 -0
  223. snowflake/connector/vendored/urllib3/request.py +191 -0
  224. snowflake/connector/vendored/urllib3/response.py +885 -0
  225. snowflake/connector/vendored/urllib3/util/__init__.py +49 -0
  226. snowflake/connector/vendored/urllib3/util/connection.py +156 -0
  227. snowflake/connector/vendored/urllib3/util/proxy.py +57 -0
  228. snowflake/connector/vendored/urllib3/util/queue.py +22 -0
  229. snowflake/connector/vendored/urllib3/util/request.py +146 -0
  230. snowflake/connector/vendored/urllib3/util/response.py +107 -0
  231. snowflake/connector/vendored/urllib3/util/retry.py +620 -0
  232. snowflake/connector/vendored/urllib3/util/ssl_.py +495 -0
  233. snowflake/connector/vendored/urllib3/util/ssl_match_hostname.py +159 -0
  234. snowflake/connector/vendored/urllib3/util/ssltransport.py +221 -0
  235. snowflake/connector/vendored/urllib3/util/timeout.py +271 -0
  236. snowflake/connector/vendored/urllib3/util/url.py +435 -0
  237. snowflake/connector/vendored/urllib3/util/wait.py +152 -0
  238. snowflake/connector/version.py +3 -0
  239. snowflake/connector/wif_util.py +407 -0
  240. snowflake_connector_python-3.16.0.dist-info/METADATA +1475 -0
  241. snowflake_connector_python-3.16.0.dist-info/RECORD +246 -0
  242. snowflake_connector_python-3.16.0.dist-info/WHEEL +5 -0
  243. snowflake_connector_python-3.16.0.dist-info/entry_points.txt +4 -0
  244. snowflake_connector_python-3.16.0.dist-info/licenses/LICENSE.txt +202 -0
  245. snowflake_connector_python-3.16.0.dist-info/licenses/NOTICE +8 -0
  246. snowflake_connector_python-3.16.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,301 @@
1
+ #!/usr/bin/env python
2
+ from __future__ import annotations
3
+
4
+ import base64
5
+ import hashlib
6
+ import logging
7
+ import random
8
+ import re
9
+ import string
10
+ from io import StringIO
11
+ from typing import Sequence
12
+
13
+ COMMENT_PATTERN_RE = re.compile(r"^\s*\-\-")
14
+ EMPTY_LINE_RE = re.compile(r"^\s*$")
15
+
16
+ _logger = logging.getLogger(__name__)
17
+
18
+
19
+ class SQLDelimiter:
20
+ """Class that wraps a SQL delimiter string.
21
+
22
+ Since split_statements is a generator this mutable object will allow it change while executing.
23
+ """
24
+
25
+ def __str__(self) -> str:
26
+ return self.sql_delimiter
27
+
28
+ def __init__(self, sql_delimiter: str = ";") -> None:
29
+ """Initializes SQLDelimiter with a string."""
30
+ self.sql_delimiter = sql_delimiter
31
+
32
+
33
+ def split_statements(
34
+ buf: StringIO,
35
+ remove_comments: bool = False,
36
+ delimiter: SQLDelimiter | None = None,
37
+ ):
38
+ """Splits a stream into SQL statements (ends with a semicolon) or commands (!...).
39
+
40
+ Args:
41
+ buf: Unicode data stream.
42
+ remove_comments: Whether or not to remove all comments (Default value = False).
43
+ delimiter: The delimiter string that separates SQL commands from each other.
44
+
45
+ Yields:
46
+ A SQL statement or a command.
47
+ """
48
+ if delimiter is None:
49
+ delimiter = SQLDelimiter() # Use default delimiter if none was given.
50
+ in_quote = False
51
+ ch_quote = None
52
+ in_comment = False
53
+ in_double_dollars = False
54
+ previous_delimiter = None
55
+
56
+ line = buf.readline()
57
+ if isinstance(line, bytes):
58
+ raise TypeError("Input data must not be binary type.")
59
+
60
+ statement = []
61
+ while line != "":
62
+ col = 0
63
+ col0 = 0
64
+ len_line = len(line)
65
+ sql_delimiter = delimiter.sql_delimiter
66
+ if not previous_delimiter or sql_delimiter != previous_delimiter:
67
+ # Only (re)compile new Regexes if they should be
68
+ escaped_delim = re.escape(sql_delimiter)
69
+ # Special characters possible in the sql delimiter are '_', '/' and ';'. If a delimiter does not end, or
70
+ # start with a special character then look for word separation with \b regex.
71
+ if re.match(r"\w", sql_delimiter[0]):
72
+ RE_START = re.compile(rf"^[^\w$]?{escaped_delim}")
73
+ else:
74
+ RE_START = re.compile(rf"^.?{escaped_delim}")
75
+ if re.match(r"\w", sql_delimiter[-1]):
76
+ RE_END = re.compile(rf"{escaped_delim}[^\w$]?$")
77
+ else:
78
+ RE_END = re.compile(rf"{escaped_delim}.?$")
79
+ previous_delimiter = sql_delimiter
80
+ while True:
81
+ if col >= len_line:
82
+ if col0 < col:
83
+ if not in_comment and not in_quote and not in_double_dollars:
84
+ statement.append((line[col0:col], True))
85
+ if len(statement) == 1 and statement[0][0] == "":
86
+ statement = []
87
+ break
88
+ elif not in_comment and (in_quote or in_double_dollars):
89
+ statement.append((line[col0:col], True))
90
+ elif not remove_comments:
91
+ statement.append((line[col0:col], False))
92
+ break
93
+ elif in_comment:
94
+ if line[col:].startswith("*/"):
95
+ in_comment = False
96
+ if not remove_comments:
97
+ statement.append((line[col0 : col + 2], False))
98
+ col += 2
99
+ col0 = col
100
+ else:
101
+ col += 1
102
+ elif in_double_dollars:
103
+ if line[col:].startswith("$$"):
104
+ in_double_dollars = False
105
+ statement.append((line[col0 : col + 2], False))
106
+ col += 2
107
+ col0 = col
108
+ else:
109
+ col += 1
110
+ elif in_quote:
111
+ if (
112
+ line[col] == "\\"
113
+ and col < len_line - 1
114
+ and line[col + 1] in (ch_quote, "\\")
115
+ ):
116
+ col += 2
117
+ elif line[col] == ch_quote:
118
+ if (
119
+ col < len_line - 1
120
+ and line[col + 1] != ch_quote
121
+ or col == len_line - 1
122
+ ):
123
+ # exits quote
124
+ in_quote = False
125
+ statement.append((line[col0 : col + 1], True))
126
+ col += 1
127
+ col0 = col
128
+ else:
129
+ # escaped quote and still in quote
130
+ col += 2
131
+ else:
132
+ col += 1
133
+ else:
134
+ if line[col] in ("'", '"'):
135
+ in_quote = True
136
+ ch_quote = line[col]
137
+ col += 1
138
+ elif line[col] in (" ", "\t"):
139
+ statement.append((line[col0 : col + 1], True))
140
+ col += 1
141
+ col0 = col
142
+ elif line[col:].startswith("--"):
143
+ statement.append((line[col0:col], True))
144
+ if not remove_comments:
145
+ # keep the comment
146
+ statement.append((line[col:], False))
147
+ else:
148
+ statement.append(("\n", True))
149
+ col = len_line + 1
150
+ col0 = col
151
+ elif line[col:].startswith("/*") and not line[col0:].startswith(
152
+ "file://"
153
+ ):
154
+ if not remove_comments:
155
+ statement.append((line[col0 : col + 2], False))
156
+ else:
157
+ statement.append((line[col0:col], False))
158
+ col += 2
159
+ col0 = col
160
+ in_comment = True
161
+ elif line[col:].startswith("$$"):
162
+ statement.append((line[col0 : col + 2], True))
163
+ col += 2
164
+ col0 = col
165
+ in_double_dollars = True
166
+ elif (
167
+ RE_START.match(line[col - 1 : col + len(sql_delimiter)])
168
+ if col > 0
169
+ else (RE_START.match(line[col : col + len(sql_delimiter)]))
170
+ ) and (RE_END.match(line[col : col + len(sql_delimiter) + 1])):
171
+ statement.append((line[col0:col] + ";", True))
172
+ col += len(sql_delimiter)
173
+ try:
174
+ if line[col] == ">":
175
+ col += 1
176
+ statement[-1] = (statement[-1][0] + ">", statement[-1][1])
177
+ except IndexError:
178
+ pass
179
+ if COMMENT_PATTERN_RE.match(line[col:]) or EMPTY_LINE_RE.match(
180
+ line[col:]
181
+ ):
182
+ if not remove_comments:
183
+ # keep the comment
184
+ statement.append((line[col:], False))
185
+ col = len_line
186
+ while col < len_line and line[col] in (" ", "\t"):
187
+ col += 1
188
+ yield _concatenate_statements(statement)
189
+ col0 = col
190
+ statement = []
191
+ elif col == 0 and line[col] == "!": # command
192
+ if len(statement) > 0:
193
+ yield _concatenate_statements(statement)
194
+ statement = []
195
+ yield (
196
+ line.strip()[: -len(sql_delimiter)]
197
+ if line.strip().endswith(sql_delimiter)
198
+ else line.strip()
199
+ ).strip(), False
200
+ break
201
+ else:
202
+ col += 1
203
+ line = buf.readline()
204
+
205
+ if len(statement) > 0:
206
+ yield _concatenate_statements(statement)
207
+
208
+
209
+ def _concatenate_statements(
210
+ statement_list: list[tuple[str, bool]]
211
+ ) -> tuple[str, bool | None]:
212
+ """Concatenate statements.
213
+
214
+ Each statement should be a tuple of statement and is_put_or_get.
215
+
216
+ The is_put_or_get is set to True if the statement is PUT or GET otherwise False for valid statement.
217
+ None is set if the statement is empty or comment only.
218
+
219
+ Args:
220
+ statement_list: List of statement parts.
221
+
222
+ Returns:
223
+ Tuple of statements and whether they are PUT or GET.
224
+ """
225
+ valid_statement_list = []
226
+ is_put_or_get = None
227
+ for text, is_statement in statement_list:
228
+ valid_statement_list.append(text)
229
+ if is_put_or_get is None and is_statement and len(text.strip()) >= 3:
230
+ is_put_or_get = text[:3].upper() in ("PUT", "GET")
231
+ return "".join(valid_statement_list).strip(), is_put_or_get
232
+
233
+
234
+ def construct_hostname(region: str | None, account: str) -> str:
235
+ """Constructs hostname from region and account."""
236
+
237
+ def _is_china_region(r: str) -> bool:
238
+ # This is consistent with the Go driver:
239
+ # https://github.com/snowflakedb/gosnowflake/blob/f20a46475dce322f3f6b97b4a72f2807571e750b/dsn.go#L535
240
+ return r.lower().startswith("cn-")
241
+
242
+ if region == "us-west-2":
243
+ region = ""
244
+ if region:
245
+ if account.find(".") > 0:
246
+ account = account[0 : account.find(".")]
247
+ top_level_domain = "cn" if _is_china_region(region) else "com"
248
+ host = f"{account}.{region}.snowflakecomputing.{top_level_domain}"
249
+ else:
250
+ top_level_domain = "com"
251
+ if account.find(".") > 0 and _is_china_region(account.split(".")[1]):
252
+ top_level_domain = "cn"
253
+ host = f"{account}.snowflakecomputing.{top_level_domain}"
254
+ return host
255
+
256
+
257
+ def parse_account(account):
258
+ url_parts = account.split(".")
259
+ # if this condition is true, then we have some extra
260
+ # stuff in the account field.
261
+ if len(url_parts) > 1:
262
+ if url_parts[1] == "global":
263
+ # remove external ID from account
264
+ parsed_account = url_parts[0][0 : url_parts[0].rfind("-")]
265
+ else:
266
+ # remove region subdomain
267
+ parsed_account = url_parts[0]
268
+ else:
269
+ parsed_account = account
270
+
271
+ return parsed_account
272
+
273
+
274
+ def random_string(
275
+ length: int = 10,
276
+ prefix: str = "",
277
+ suffix: str = "",
278
+ choices: Sequence[str] = string.ascii_lowercase,
279
+ ) -> str:
280
+ """Our convenience function to generate random string for object names.
281
+
282
+ Args:
283
+ length: How many random characters to choose from choices.
284
+ prefix: Prefix to add to random string generated.
285
+ suffix: Suffix to add to random string generated.
286
+ choices: A generator of things to choose from.
287
+ """
288
+ random_part = "".join([random.Random().choice(choices) for _ in range(length)])
289
+ return "".join([prefix, random_part, suffix])
290
+
291
+
292
+ def _base64_bytes_to_str(x) -> str | None:
293
+ return base64.b64encode(x).decode("utf-8") if x else None
294
+
295
+
296
+ def get_md5(text: str | bytes) -> bytes:
297
+ if isinstance(text, str):
298
+ text = text.encode("utf-8")
299
+ md5 = hashlib.md5()
300
+ md5.update(text)
301
+ return md5.digest()
@@ -0,0 +1,3 @@
1
+ #
2
+ # Copyright (c) 2012-2021 Snowflake Computing Inc. All rights reserved.
3
+ #
@@ -0,0 +1,175 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
@@ -0,0 +1,169 @@
1
+ # __
2
+ # /__) _ _ _ _ _/ _
3
+ # / ( (- (/ (/ (- _) / _)
4
+ # /
5
+
6
+ """
7
+ Requests HTTP Library
8
+ ~~~~~~~~~~~~~~~~~~~~~
9
+
10
+ Requests is an HTTP library, written in Python, for human beings.
11
+ Basic GET usage:
12
+
13
+ >>> import requests
14
+ >>> r = requests.get('https://www.python.org')
15
+ >>> r.status_code
16
+ 200
17
+ >>> b'Python is a programming language' in r.content
18
+ True
19
+
20
+ ... or POST:
21
+
22
+ >>> payload = dict(key1='value1', key2='value2')
23
+ >>> r = requests.post('https://httpbin.org/post', data=payload)
24
+ >>> print(r.text)
25
+ {
26
+ ...
27
+ "form": {
28
+ "key1": "value1",
29
+ "key2": "value2"
30
+ },
31
+ ...
32
+ }
33
+
34
+ The other HTTP methods are supported - see `requests.api`. Full documentation
35
+ is at <https://requests.readthedocs.io>.
36
+
37
+ :copyright: (c) 2017 by Kenneth Reitz.
38
+ :license: Apache 2.0, see LICENSE for more details.
39
+ """
40
+
41
+ import warnings
42
+
43
+ from .. import urllib3
44
+ from .exceptions import RequestsDependencyWarning
45
+
46
+ try:
47
+ from charset_normalizer import __version__ as charset_normalizer_version
48
+ except ImportError:
49
+ charset_normalizer_version = None
50
+
51
+ try:
52
+ from chardet import __version__ as chardet_version
53
+ except ImportError:
54
+ chardet_version = None
55
+
56
+
57
+ def check_compatibility(urllib3_version, chardet_version, charset_normalizer_version):
58
+ urllib3_version = urllib3_version.split(".")
59
+ assert urllib3_version != ["dev"] # Verify urllib3 isn't installed from git.
60
+
61
+ # Sometimes, urllib3 only reports its version as 16.1.
62
+ if len(urllib3_version) == 2:
63
+ urllib3_version.append("0")
64
+
65
+ # Check urllib3 for compatibility.
66
+ major, minor, patch = urllib3_version # noqa: F811
67
+ major, minor, patch = int(major), int(minor), int(patch)
68
+ # urllib3 >= 1.21.1
69
+ assert major >= 1
70
+ if major == 1:
71
+ assert minor >= 21
72
+
73
+ # Check charset_normalizer for compatibility.
74
+ if chardet_version:
75
+ major, minor, patch = chardet_version.split(".")[:3]
76
+ major, minor, patch = int(major), int(minor), int(patch)
77
+ # chardet_version >= 3.0.2, < 6.0.0
78
+ assert (3, 0, 2) <= (major, minor, patch) < (6, 0, 0)
79
+ elif charset_normalizer_version:
80
+ major, minor, patch = charset_normalizer_version.split(".")[:3]
81
+ major, minor, patch = int(major), int(minor), int(patch)
82
+ # charset_normalizer >= 2.0.0 < 4.0.0
83
+ assert (2, 0, 0) <= (major, minor, patch) < (4, 0, 0)
84
+ else:
85
+ raise Exception("You need either charset_normalizer or chardet installed")
86
+
87
+
88
+ def _check_cryptography(cryptography_version):
89
+ # cryptography < 1.3.4
90
+ try:
91
+ cryptography_version = list(map(int, cryptography_version.split(".")))
92
+ except ValueError:
93
+ return
94
+
95
+ if cryptography_version < [1, 3, 4]:
96
+ warning = "Old version of cryptography ({}) may cause slowdown.".format(
97
+ cryptography_version
98
+ )
99
+ warnings.warn(warning, RequestsDependencyWarning)
100
+
101
+
102
+ # Check imported dependencies for compatibility.
103
+ try:
104
+ check_compatibility(
105
+ urllib3.__version__, chardet_version, charset_normalizer_version
106
+ )
107
+ except (AssertionError, ValueError):
108
+ warnings.warn(
109
+ "urllib3 ({}) or chardet ({})/charset_normalizer ({}) doesn't match a supported "
110
+ "version!".format(
111
+ urllib3.__version__, chardet_version, charset_normalizer_version
112
+ ),
113
+ RequestsDependencyWarning,
114
+ )
115
+
116
+ # Attempt to enable urllib3's SNI support, if possible
117
+ try:
118
+ from ..urllib3.contrib import pyopenssl
119
+ pyopenssl.inject_into_urllib3()
120
+
121
+ # Check cryptography version
122
+ from cryptography import __version__ as cryptography_version
123
+ _check_cryptography(cryptography_version)
124
+ except ImportError:
125
+ pass
126
+
127
+ # urllib3's DependencyWarnings should be silenced.
128
+ from ..urllib3.exceptions import DependencyWarning
129
+
130
+ warnings.simplefilter("ignore", DependencyWarning)
131
+
132
+ # Set default logging handler to avoid "No handler found" warnings.
133
+ import logging
134
+ from logging import NullHandler
135
+
136
+ from . import utils
137
+ from .__version__ import (
138
+ __author__,
139
+ __author_email__,
140
+ __build__,
141
+ __cake__,
142
+ __copyright__,
143
+ __description__,
144
+ __license__,
145
+ __title__,
146
+ __url__,
147
+ __version__,
148
+ )
149
+ from .api import delete, get, head, options, patch, post, put, request
150
+ from .exceptions import (
151
+ ConnectionError,
152
+ ConnectTimeout,
153
+ FileModeWarning,
154
+ HTTPError,
155
+ JSONDecodeError,
156
+ ReadTimeout,
157
+ RequestException,
158
+ Timeout,
159
+ TooManyRedirects,
160
+ URLRequired,
161
+ )
162
+ from .models import PreparedRequest, Request, Response
163
+ from .sessions import Session, session
164
+ from .status_codes import codes
165
+
166
+ logging.getLogger(__name__).addHandler(NullHandler())
167
+
168
+ # FileModeWarnings go off per the default.
169
+ warnings.simplefilter("default", FileModeWarning, append=True)
@@ -0,0 +1,14 @@
1
+ # .-. .-. .-. . . .-. .-. .-. .-.
2
+ # |( |- |.| | | |- `-. | `-.
3
+ # ' ' `-' `-`.`-' `-' `-' ' `-'
4
+
5
+ __title__ = "requests"
6
+ __description__ = "Python HTTP for Humans."
7
+ __url__ = "https://requests.readthedocs.io"
8
+ __version__ = "2.31.0"
9
+ __build__ = 0x023100
10
+ __author__ = "Kenneth Reitz"
11
+ __author_email__ = "me@kennethreitz.org"
12
+ __license__ = "Apache 2.0"
13
+ __copyright__ = "Copyright Kenneth Reitz"
14
+ __cake__ = "\u2728 \U0001f370 \u2728"