wherobots-python-dbapi 0.27.0__py3-none-any.whl → 0.28.0__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.
- wherobots/db/driver.py +28 -10
- {wherobots_python_dbapi-0.27.0.dist-info → wherobots_python_dbapi-0.28.0.dist-info}/METADATA +11 -1
- {wherobots_python_dbapi-0.27.0.dist-info → wherobots_python_dbapi-0.28.0.dist-info}/RECORD +5 -5
- {wherobots_python_dbapi-0.27.0.dist-info → wherobots_python_dbapi-0.28.0.dist-info}/WHEEL +0 -0
- {wherobots_python_dbapi-0.27.0.dist-info → wherobots_python_dbapi-0.28.0.dist-info}/licenses/LICENSE +0 -0
wherobots/db/driver.py
CHANGED
|
@@ -21,8 +21,6 @@ import certifi
|
|
|
21
21
|
from .connection import Connection
|
|
22
22
|
from .constants import (
|
|
23
23
|
DEFAULT_ENDPOINT,
|
|
24
|
-
DEFAULT_REGION,
|
|
25
|
-
DEFAULT_RUNTIME,
|
|
26
24
|
DEFAULT_READ_TIMEOUT_SECONDS,
|
|
27
25
|
DEFAULT_SESSION_TYPE,
|
|
28
26
|
DEFAULT_SESSION_WAIT_TIMEOUT_SECONDS,
|
|
@@ -72,8 +70,8 @@ def connect(
|
|
|
72
70
|
host: str = DEFAULT_ENDPOINT,
|
|
73
71
|
token: Union[str, None] = None,
|
|
74
72
|
api_key: Union[str, None] = None,
|
|
75
|
-
runtime: Union[Runtime, None] = None,
|
|
76
|
-
region: Union[Region, None] = None,
|
|
73
|
+
runtime: Union[str, Runtime, None] = None,
|
|
74
|
+
region: Union[str, Region, None] = None,
|
|
77
75
|
version: Union[str, None] = None,
|
|
78
76
|
wait_timeout: float = DEFAULT_SESSION_WAIT_TIMEOUT_SECONDS,
|
|
79
77
|
read_timeout: float = DEFAULT_READ_TIMEOUT_SECONDS,
|
|
@@ -85,6 +83,20 @@ def connect(
|
|
|
85
83
|
geometry_representation: Union[GeometryRepresentation, None] = None,
|
|
86
84
|
cancel_event: Union[threading.Event, None] = None,
|
|
87
85
|
) -> Connection:
|
|
86
|
+
"""Create a connection to a Wherobots SQL session.
|
|
87
|
+
|
|
88
|
+
:param runtime: The compute runtime to use. Accepts a ``Runtime`` enum value
|
|
89
|
+
or a raw string; strings are passed to the API as-is. Override the
|
|
90
|
+
default runtime set for your organization — only set this if you need a
|
|
91
|
+
specific runtime instead of the one your administrator has configured.
|
|
92
|
+
When omitted, your organization's default runtime is used.
|
|
93
|
+
:param region: The compute region to run in. Accepts a ``Region`` enum value
|
|
94
|
+
or a raw string (e.g. a BYOC region such as ``byoc-acme-us-east-1``);
|
|
95
|
+
strings are passed to the API as-is. Override the default region set for
|
|
96
|
+
your organization — only set this if you intend to use a specific region
|
|
97
|
+
instead of the one your administrator has configured. When omitted, your
|
|
98
|
+
organization's default region is used.
|
|
99
|
+
"""
|
|
88
100
|
if not token and not api_key:
|
|
89
101
|
raise ValueError("At least one of `token` or `api_key` is required")
|
|
90
102
|
if token and api_key:
|
|
@@ -97,16 +109,20 @@ def connect(
|
|
|
97
109
|
headers["X-API-Key"] = api_key
|
|
98
110
|
|
|
99
111
|
host = host or DEFAULT_ENDPOINT
|
|
100
|
-
runtime = runtime or DEFAULT_RUNTIME
|
|
101
|
-
region = region or DEFAULT_REGION
|
|
102
112
|
session_type = session_type or DEFAULT_SESSION_TYPE
|
|
103
113
|
|
|
114
|
+
# Normalize enum values to their string form and pass raw strings through
|
|
115
|
+
# untouched. When omitted (None) the field is dropped from the request so
|
|
116
|
+
# the API applies the organization's configured default.
|
|
117
|
+
runtime_id = runtime.value if isinstance(runtime, Runtime) else runtime
|
|
118
|
+
region_name = region.value if isinstance(region, Region) else region
|
|
119
|
+
|
|
104
120
|
logging.info(
|
|
105
121
|
"Requesting %s%s runtime %sin %s from %s ...",
|
|
106
122
|
"new " if force_new else "",
|
|
107
|
-
|
|
123
|
+
runtime_id or "org-default",
|
|
108
124
|
f"running {version} " if version else "",
|
|
109
|
-
|
|
125
|
+
region_name or "org-default",
|
|
110
126
|
host,
|
|
111
127
|
)
|
|
112
128
|
|
|
@@ -119,9 +135,11 @@ def connect(
|
|
|
119
135
|
try:
|
|
120
136
|
resp = requests.post(
|
|
121
137
|
url=f"{host}/sql/session",
|
|
122
|
-
params
|
|
138
|
+
# `requests` omits query params whose value is None, so an omitted
|
|
139
|
+
# region is simply not sent and the API applies the org default.
|
|
140
|
+
params={"region": region_name, "force_new": force_new},
|
|
123
141
|
json={
|
|
124
|
-
"runtimeId":
|
|
142
|
+
"runtimeId": runtime_id,
|
|
125
143
|
"shutdownAfterInactiveSeconds": shutdown_after_inactive_seconds,
|
|
126
144
|
"version": version,
|
|
127
145
|
"sessionType": session_type.value,
|
{wherobots_python_dbapi-0.27.0.dist-info → wherobots_python_dbapi-0.28.0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wherobots-python-dbapi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.28.0
|
|
4
4
|
Summary: Python DB-API driver for Wherobots DB
|
|
5
5
|
Project-URL: Homepage, https://github.com/wherobots/wherobots-python-dbapi-driver
|
|
6
6
|
Project-URL: Tracker, https://github.com/wherobots/wherobots-python-dbapi-driver/issues
|
|
@@ -107,6 +107,16 @@ with connect(
|
|
|
107
107
|
print(results)
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
`runtime` and `region` are optional and accept either the provided enums (handy
|
|
111
|
+
for autocomplete) or a plain string — strings are passed to the API as-is, so
|
|
112
|
+
new or BYOC regions (e.g. `region="byoc-acme-us-east-1"`) work without an SDK
|
|
113
|
+
upgrade. When omitted, your organization's configured defaults are used:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
with connect(api_key='...') as conn: # uses your org's default runtime + region
|
|
117
|
+
...
|
|
118
|
+
```
|
|
119
|
+
|
|
110
120
|
The `Cursor` supports the context manager protocol, so you can use it
|
|
111
121
|
within a `with` statement when needed:
|
|
112
122
|
|
|
@@ -3,14 +3,14 @@ wherobots/db/__init__.py,sha256=HN_uGOUMor80GB3rZIqnPcYWDAia7QAC-y9HfGKnegs,744
|
|
|
3
3
|
wherobots/db/connection.py,sha256=BWQwVzFgujEwPKvhDePM9q45M2opCk6Jq998L0ekMyY,12795
|
|
4
4
|
wherobots/db/constants.py,sha256=qV-6CmOya7-f-DoRMzcDzlhcmV5PkLCcqG5TFIsxQ7o,744
|
|
5
5
|
wherobots/db/cursor.py,sha256=Z0rNdhJ985IP9XnZpjrCzvM0OqDFVgCNfJn8lrbijAo,6809
|
|
6
|
-
wherobots/db/driver.py,sha256=
|
|
6
|
+
wherobots/db/driver.py,sha256=fHfYtujvafmAnJh9uf_0oZUNVtyf8XLsgs9sqfiDMk4,10304
|
|
7
7
|
wherobots/db/errors.py,sha256=G8a-DB6pgB0pUld59Wyq8PuywL-JWxGJfvrr-g8BPuU,310
|
|
8
8
|
wherobots/db/models.py,sha256=uk0EqZMH_RFkQusSw2AvyFivGvGJBu_WYP8FHa6JJGM,4178
|
|
9
9
|
wherobots/db/region.py,sha256=GoFzazvgOjE1kVVT1QKAsRK88c_1XSAebR3ME4foSlQ,400
|
|
10
10
|
wherobots/db/runtime.py,sha256=eAR1oJEtssgkp-IRPTLOrlPI-_5SM_ASw6T6hQ_qF4I,985
|
|
11
11
|
wherobots/db/session_type.py,sha256=jZNwCl0nxvY-0reIn8RR_-fIYSSvIcaGx_4pRc71Lww,137
|
|
12
12
|
wherobots/db/types.py,sha256=WXKT_gbdQCH2_yXD_FECk0BpB7yfNWOLewCfax0U_Lk,2516
|
|
13
|
-
wherobots_python_dbapi-0.
|
|
14
|
-
wherobots_python_dbapi-0.
|
|
15
|
-
wherobots_python_dbapi-0.
|
|
16
|
-
wherobots_python_dbapi-0.
|
|
13
|
+
wherobots_python_dbapi-0.28.0.dist-info/METADATA,sha256=qUqbExsrE8Q6GwBE8f_mWL8-yNnGAp4vY1qgc_2OU0c,11142
|
|
14
|
+
wherobots_python_dbapi-0.28.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
15
|
+
wherobots_python_dbapi-0.28.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
16
|
+
wherobots_python_dbapi-0.28.0.dist-info/RECORD,,
|
|
File without changes
|
{wherobots_python_dbapi-0.27.0.dist-info → wherobots_python_dbapi-0.28.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|