snowflake-sql-api 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.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_sql_api/__init__.py +2 -0
- snowflake_sql_api/_version.py +2 -2
- snowflake_sql_api/cli.py +1 -1
- snowflake_sql_api/exceptions.py +10 -0
- snowflake_sql_api/testing.py +6 -2
- snowflake_sql_api/transport.py +14 -4
- {snowflake_sql_api-0.1.0.dist-info → snowflake_sql_api-0.1.2.dist-info}/METADATA +6 -5
- {snowflake_sql_api-0.1.0.dist-info → snowflake_sql_api-0.1.2.dist-info}/RECORD +11 -11
- {snowflake_sql_api-0.1.0.dist-info → snowflake_sql_api-0.1.2.dist-info}/WHEEL +1 -1
- {snowflake_sql_api-0.1.0.dist-info → snowflake_sql_api-0.1.2.dist-info}/entry_points.txt +0 -0
- {snowflake_sql_api-0.1.0.dist-info → snowflake_sql_api-0.1.2.dist-info}/licenses/LICENSE +0 -0
snowflake_sql_api/__init__.py
CHANGED
|
@@ -33,6 +33,7 @@ from .exceptions import (
|
|
|
33
33
|
SnowflakeAuthError,
|
|
34
34
|
SnowflakeConfigError,
|
|
35
35
|
SnowflakeError,
|
|
36
|
+
SnowflakeForbiddenError,
|
|
36
37
|
SnowflakeProgrammingError,
|
|
37
38
|
SnowflakeRequestError,
|
|
38
39
|
SnowflakeRetryError,
|
|
@@ -51,6 +52,7 @@ __all__ = [
|
|
|
51
52
|
"SnowflakeConfigError",
|
|
52
53
|
"SnowflakeAuthError",
|
|
53
54
|
"SnowflakeRequestError",
|
|
55
|
+
"SnowflakeForbiddenError",
|
|
54
56
|
"SnowflakeProgrammingError",
|
|
55
57
|
"SnowflakeTimeoutError",
|
|
56
58
|
"SnowflakeRetryError",
|
snowflake_sql_api/_version.py
CHANGED
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.1.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 1,
|
|
21
|
+
__version__ = version = '0.1.2'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 2)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
snowflake_sql_api/cli.py
CHANGED
|
@@ -68,7 +68,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
|
|
|
68
68
|
return 2
|
|
69
69
|
if args.command == "query":
|
|
70
70
|
return _run_query(args.sql)
|
|
71
|
-
return 0
|
|
71
|
+
return 0 # pragma: no cover - argparse only yields None or a known subcommand
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
if __name__ == "__main__": # pragma: no cover
|
snowflake_sql_api/exceptions.py
CHANGED
|
@@ -14,6 +14,7 @@ __all__ = [
|
|
|
14
14
|
"SnowflakeConfigError",
|
|
15
15
|
"SnowflakeAuthError",
|
|
16
16
|
"SnowflakeRequestError",
|
|
17
|
+
"SnowflakeForbiddenError",
|
|
17
18
|
"SnowflakeProgrammingError",
|
|
18
19
|
"SnowflakeTimeoutError",
|
|
19
20
|
"SnowflakeRetryError",
|
|
@@ -62,6 +63,15 @@ class SnowflakeRequestError(SnowflakeError):
|
|
|
62
63
|
self.statement_handle = statement_handle
|
|
63
64
|
|
|
64
65
|
|
|
66
|
+
class SnowflakeForbiddenError(SnowflakeRequestError):
|
|
67
|
+
"""Snowflake refused an authenticated request (HTTP 403).
|
|
68
|
+
|
|
69
|
+
The JWT was accepted but the request is not allowed, so retrying with the
|
|
70
|
+
same identity will not help. A subclass of :class:`SnowflakeRequestError`,
|
|
71
|
+
so existing handlers for that type still catch it.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
|
|
65
75
|
class SnowflakeProgrammingError(SnowflakeRequestError):
|
|
66
76
|
"""The submitted SQL failed to compile or execute (HTTP 422).
|
|
67
77
|
|
snowflake_sql_api/testing.py
CHANGED
|
@@ -599,7 +599,7 @@ def make_client(
|
|
|
599
599
|
from .client import SnowflakeClient
|
|
600
600
|
|
|
601
601
|
_reject_managed_kwargs("make_client", kwargs)
|
|
602
|
-
|
|
602
|
+
client = SnowflakeClient(
|
|
603
603
|
account,
|
|
604
604
|
user,
|
|
605
605
|
private_key=_throwaway_key(),
|
|
@@ -607,6 +607,8 @@ def make_client(
|
|
|
607
607
|
poll_interval=poll_interval,
|
|
608
608
|
**kwargs,
|
|
609
609
|
)
|
|
610
|
+
client._transport._owns_client = True
|
|
611
|
+
return client
|
|
610
612
|
|
|
611
613
|
|
|
612
614
|
def make_async_client(
|
|
@@ -621,7 +623,7 @@ def make_async_client(
|
|
|
621
623
|
from .aclient import AsyncSnowflakeClient
|
|
622
624
|
|
|
623
625
|
_reject_managed_kwargs("make_async_client", kwargs)
|
|
624
|
-
|
|
626
|
+
client = AsyncSnowflakeClient(
|
|
625
627
|
account,
|
|
626
628
|
user,
|
|
627
629
|
private_key=_throwaway_key(),
|
|
@@ -629,6 +631,8 @@ def make_async_client(
|
|
|
629
631
|
poll_interval=poll_interval,
|
|
630
632
|
**kwargs,
|
|
631
633
|
)
|
|
634
|
+
client._transport._owns_client = True
|
|
635
|
+
return client
|
|
632
636
|
|
|
633
637
|
|
|
634
638
|
# ---------------------------------------------------------------------------
|
snowflake_sql_api/transport.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"""HTTP transport against ``POST /api/v2/statements``.
|
|
2
2
|
|
|
3
3
|
Owns the actual ``httpx`` calls (sync and async), status-code interpretation
|
|
4
|
-
(200 success, 202 long-running/async, 422 execution failure, 401 auth,
|
|
5
|
-
retryable), the retry loop, and ``requestId`` reuse for
|
|
6
|
-
retried submit re-POSTs the identical body with the same
|
|
7
|
-
``retry=true`` so Snowflake deduplicates instead of
|
|
4
|
+
(200 success, 202 long-running/async, 422 execution failure, 401 auth,
|
|
5
|
+
403 forbidden, 429/5xx retryable), the retry loop, and ``requestId`` reuse for
|
|
6
|
+
idempotent retries. A retried submit re-POSTs the identical body with the same
|
|
7
|
+
``requestId`` and ``retry=true`` so Snowflake deduplicates instead of
|
|
8
|
+
double-applying DML.
|
|
8
9
|
|
|
9
10
|
Higher layers (``client``/``aclient``) talk to the transport, not to ``httpx``.
|
|
10
11
|
"""
|
|
@@ -19,6 +20,7 @@ import httpx
|
|
|
19
20
|
|
|
20
21
|
from .exceptions import (
|
|
21
22
|
SnowflakeAuthError,
|
|
23
|
+
SnowflakeForbiddenError,
|
|
22
24
|
SnowflakeProgrammingError,
|
|
23
25
|
SnowflakeRequestError,
|
|
24
26
|
SnowflakeRetryError,
|
|
@@ -84,6 +86,14 @@ def _interpret(response: httpx.Response) -> StatementResponse:
|
|
|
84
86
|
)
|
|
85
87
|
if status == 401:
|
|
86
88
|
raise SnowflakeAuthError(body.get("message", "authentication failed"))
|
|
89
|
+
if status == 403:
|
|
90
|
+
raise SnowflakeForbiddenError(
|
|
91
|
+
body.get("message", "request forbidden"),
|
|
92
|
+
status_code=status,
|
|
93
|
+
code=body.get("code"),
|
|
94
|
+
sql_state=body.get("sqlState"),
|
|
95
|
+
statement_handle=body.get("statementHandle"),
|
|
96
|
+
)
|
|
87
97
|
raise SnowflakeRequestError(
|
|
88
98
|
body.get("message", f"HTTP {status}"),
|
|
89
99
|
status_code=status,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: snowflake-sql-api
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Lightweight, pure-Python client for Snowflake's SQL API v2
|
|
5
5
|
Project-URL: Homepage, https://github.com/hampsterx/snowflake-sql-api
|
|
6
6
|
Project-URL: Repository, https://github.com/hampsterx/snowflake-sql-api
|
|
@@ -72,9 +72,10 @@ A lightweight, pure-Python client for [Snowflake's SQL API v2](https://docs.snow
|
|
|
72
72
|
## Why
|
|
73
73
|
|
|
74
74
|
The official [`snowflake-connector-python`](https://pypi.org/project/snowflake-connector-python/)
|
|
75
|
-
is ~75 MB installed (150 MB with pandas/pyarrow)
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
is ~75 MB installed (150 MB with pandas/pyarrow) and ships a compiled extension
|
|
76
|
+
that slows container builds and inflates cold starts (its import alone is ~1.5 s
|
|
77
|
+
versus ~0.3 s for this client). For serverless and AWS Lambda workloads that only
|
|
78
|
+
need to run SQL, that is a lot of weight.
|
|
78
79
|
|
|
79
80
|
`snowflake-sql-api` talks to Snowflake's SQL API over plain HTTP (`httpx`), so it
|
|
80
81
|
stays small and cold-starts quickly. Core dependencies: `httpx`, `PyJWT`,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
snowflake_sql_api/__init__.py,sha256=
|
|
2
|
-
snowflake_sql_api/_version.py,sha256=
|
|
1
|
+
snowflake_sql_api/__init__.py,sha256=MIhD7NbOxroK3XNtH2zuF72F8SUEas8Mej4cKrHP1gk,1848
|
|
2
|
+
snowflake_sql_api/_version.py,sha256=Q6ScJXlkBsUI-cazSvpYPMyIVUB-Vd0R3pq3_rM1wmI,520
|
|
3
3
|
snowflake_sql_api/aclient.py,sha256=nfxH9OkgIaWEppKiL86mziZaNU9GYL4y1vYCFxUReBc,12106
|
|
4
4
|
snowflake_sql_api/auth.py,sha256=kenkotGbzwZVF3MMZp5NRXXqmQSdd5HffEWbFv-X3vQ,6904
|
|
5
5
|
snowflake_sql_api/bindings.py,sha256=affZsvBFYK1XRLAsNK5O4BFdjNaBp-jMi4oqV9Y7Kmg,4167
|
|
6
|
-
snowflake_sql_api/cli.py,sha256=
|
|
6
|
+
snowflake_sql_api/cli.py,sha256=OlOHBKp71MnXmn7pLJiBKkH1prrwXZfXq1PwXgEc1o0,2363
|
|
7
7
|
snowflake_sql_api/client.py,sha256=yif4E-pM19M4nCKu_atlOLqjOJjYtTbep3bKJtVbUuc,13653
|
|
8
8
|
snowflake_sql_api/escaping.py,sha256=B9-IcXCAQC3DlZvfXAYV6s07wDpxHvcj27XC9snwzZo,2122
|
|
9
|
-
snowflake_sql_api/exceptions.py,sha256=
|
|
9
|
+
snowflake_sql_api/exceptions.py,sha256=zJiXJeVLNdy1jex4zchIIgMYNr643uaSLZEMMmngT3g,3374
|
|
10
10
|
snowflake_sql_api/pagination.py,sha256=I_L7cPTamvyW06Za-MX06OXEMtLavH574mbGeJa_F0U,1985
|
|
11
11
|
snowflake_sql_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
snowflake_sql_api/retry.py,sha256=Td2xjOWbZeWyiuaXETEvIs8fx8RnQeBlBtkR5u36-Ys,2450
|
|
13
13
|
snowflake_sql_api/row_mapping.py,sha256=Tbfcp7SMJNjIUVS_ppP2E2DZRsjy2BP0a2F0x4DaIEk,728
|
|
14
|
-
snowflake_sql_api/testing.py,sha256=
|
|
15
|
-
snowflake_sql_api/transport.py,sha256=
|
|
14
|
+
snowflake_sql_api/testing.py,sha256=o01frcPjdLklqTVLD2ty2A3yu7BJ71ErWRZ23jaSssY,24004
|
|
15
|
+
snowflake_sql_api/transport.py,sha256=kSwhuyMZw8AtxNkIoeP8Zj2azdbf6hoEB3tGSW3FHb8,10621
|
|
16
16
|
snowflake_sql_api/types.py,sha256=rc2ykc0Gj3BrIFlCqxrxisaWvR00pVp9qASKPlt4qYw,6364
|
|
17
|
-
snowflake_sql_api-0.1.
|
|
18
|
-
snowflake_sql_api-0.1.
|
|
19
|
-
snowflake_sql_api-0.1.
|
|
20
|
-
snowflake_sql_api-0.1.
|
|
21
|
-
snowflake_sql_api-0.1.
|
|
17
|
+
snowflake_sql_api-0.1.2.dist-info/METADATA,sha256=co8hplULGL2uxfqwGkq3171H38uPI_ZDR0wf8s6GjoI,6987
|
|
18
|
+
snowflake_sql_api-0.1.2.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
19
|
+
snowflake_sql_api-0.1.2.dist-info/entry_points.txt,sha256=__k9ZNjqRWfFCiDslpV2LnTogH5I6pOWRqau-oaGPm8,123
|
|
20
|
+
snowflake_sql_api-0.1.2.dist-info/licenses/LICENSE,sha256=0Gk5s9Wzw2HmN_HtpZrvQPR87lTF_KU2ZrV0lExA6J4,1066
|
|
21
|
+
snowflake_sql_api-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|