wherobots-python-dbapi 0.7.2__tar.gz → 0.7.4__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.
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/PKG-INFO +4 -3
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/pyproject.toml +5 -3
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/wherobots/db/cursor.py +30 -4
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/wherobots/db/driver.py +19 -2
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/wherobots/db/runtime.py +6 -6
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/LICENSE +0 -0
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/README.md +0 -0
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/wherobots/__init__.py +0 -0
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/wherobots/db/__init__.py +0 -0
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/wherobots/db/connection.py +0 -0
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/wherobots/db/constants.py +0 -0
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/wherobots/db/errors.py +0 -0
- {wherobots_python_dbapi-0.7.2 → wherobots_python_dbapi-0.7.4}/wherobots/db/region.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: wherobots-python-dbapi
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.4
|
|
4
4
|
Summary: Python DB-API driver for Wherobots DB
|
|
5
5
|
License: Apache 2.0
|
|
6
6
|
Author: Maxime Petazzoni
|
|
@@ -14,8 +14,9 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Requires-Dist: StrEnum (>=0.4.15,<0.5.0)
|
|
16
16
|
Requires-Dist: cbor2 (>=5.6.3,<6.0.0)
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist:
|
|
17
|
+
Requires-Dist: numpy (<2)
|
|
18
|
+
Requires-Dist: pandas (>=2.1.0,<3.0.0)
|
|
19
|
+
Requires-Dist: pyarrow (>=14.0.2,<15.0.0)
|
|
19
20
|
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
20
21
|
Requires-Dist: tenacity (>=8.2.3,<9.0.0)
|
|
21
22
|
Requires-Dist: websockets (>=12.0,<13.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "wherobots-python-dbapi"
|
|
3
|
-
version = "0.7.
|
|
3
|
+
version = "0.7.4"
|
|
4
4
|
description = "Python DB-API driver for Wherobots DB"
|
|
5
5
|
authors = ["Maxime Petazzoni <max@wherobots.com>"]
|
|
6
6
|
license = "Apache 2.0"
|
|
@@ -16,10 +16,12 @@ python = "^3.9"
|
|
|
16
16
|
requests = "^2.31.0"
|
|
17
17
|
websockets = "^12.0"
|
|
18
18
|
tenacity = "^8.2.3"
|
|
19
|
-
pyarrow = "^
|
|
19
|
+
pyarrow = "^14.0.2"
|
|
20
20
|
cbor2 = "^5.6.3"
|
|
21
|
-
pandas = "^2.
|
|
21
|
+
pandas = "^2.1.0"
|
|
22
22
|
StrEnum = "^0.4.15"
|
|
23
|
+
# pyarrow 14.0.2 doesn't limit numpy < 2, but it should, we do it here
|
|
24
|
+
numpy = "<2"
|
|
23
25
|
|
|
24
26
|
[tool.poetry.group.dev.dependencies]
|
|
25
27
|
mypy = "^1.8.0"
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import queue
|
|
2
|
-
from typing import Any, Optional
|
|
2
|
+
from typing import Any, Optional, List, Tuple
|
|
3
3
|
|
|
4
4
|
from .errors import ProgrammingError, DatabaseError
|
|
5
5
|
|
|
6
|
+
_TYPE_MAP = {
|
|
7
|
+
"object": "STRING",
|
|
8
|
+
"int64": "NUMBER",
|
|
9
|
+
"float64": "NUMBER",
|
|
10
|
+
"datetime64[ns]": "DATETIME",
|
|
11
|
+
"timedelta[ns]": "DATETIME",
|
|
12
|
+
"bool": "NUMBER", # Assuming boolean is stored as number
|
|
13
|
+
"bytes": "BINARY",
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
|
|
7
17
|
class Cursor:
|
|
8
18
|
|
|
@@ -17,14 +27,14 @@ class Cursor:
|
|
|
17
27
|
|
|
18
28
|
# Description and row count are set by the last executed operation.
|
|
19
29
|
# Their default values are defined by PEP-0249.
|
|
20
|
-
self.__description: Optional[
|
|
30
|
+
self.__description: Optional[List[Tuple]] = None
|
|
21
31
|
self.__rowcount: int = -1
|
|
22
32
|
|
|
23
33
|
# Array-size is also defined by PEP-0249 and is expected to be read/writable.
|
|
24
34
|
self.arraysize: int = 1
|
|
25
35
|
|
|
26
36
|
@property
|
|
27
|
-
def description(self) -> Optional[
|
|
37
|
+
def description(self) -> Optional[List[Tuple]]:
|
|
28
38
|
return self.__description
|
|
29
39
|
|
|
30
40
|
@property
|
|
@@ -34,7 +44,7 @@ class Cursor:
|
|
|
34
44
|
def __on_execution_result(self, result) -> None:
|
|
35
45
|
self.__queue.put(result)
|
|
36
46
|
|
|
37
|
-
def __get_results(self) -> Optional[
|
|
47
|
+
def __get_results(self) -> Optional[List[Tuple[Any, ...]]]:
|
|
38
48
|
if not self.__current_execution_id:
|
|
39
49
|
raise ProgrammingError("No query has been executed yet")
|
|
40
50
|
if self.__results is not None:
|
|
@@ -43,8 +53,23 @@ class Cursor:
|
|
|
43
53
|
result = self.__queue.get()
|
|
44
54
|
if isinstance(result, DatabaseError):
|
|
45
55
|
raise result
|
|
56
|
+
|
|
46
57
|
self.__rowcount = len(result)
|
|
47
58
|
self.__results = result
|
|
59
|
+
if not result.empty:
|
|
60
|
+
self.__description = [
|
|
61
|
+
(
|
|
62
|
+
col_name, # name
|
|
63
|
+
_TYPE_MAP.get(str(result[col_name].dtype), "STRING"), # type_code
|
|
64
|
+
None, # display_size
|
|
65
|
+
result[col_name].memory_usage(), # internal_size
|
|
66
|
+
None, # precision
|
|
67
|
+
None, # scale
|
|
68
|
+
True, # null_ok; Assuming all columns can accept NULL values
|
|
69
|
+
)
|
|
70
|
+
for col_name in result.columns
|
|
71
|
+
]
|
|
72
|
+
|
|
48
73
|
return self.__results
|
|
49
74
|
|
|
50
75
|
def execute(self, operation: str, parameters: dict[str, Any] = None):
|
|
@@ -54,6 +79,7 @@ class Cursor:
|
|
|
54
79
|
self.__results = None
|
|
55
80
|
self.__current_row = 0
|
|
56
81
|
self.__rowcount = -1
|
|
82
|
+
self.__description = None
|
|
57
83
|
|
|
58
84
|
sql = operation.format(**(parameters or {}))
|
|
59
85
|
self.__current_execution_id = self.__exec_fn(sql, self.__on_execution_result)
|
|
@@ -4,9 +4,12 @@ A PEP-0249 compatible driver for interfacing with Wherobots DB.
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
import logging
|
|
7
|
-
import
|
|
7
|
+
import platform
|
|
8
8
|
import urllib.parse
|
|
9
9
|
import queue
|
|
10
|
+
from importlib import metadata
|
|
11
|
+
from importlib.metadata import PackageNotFoundError
|
|
12
|
+
|
|
10
13
|
import requests
|
|
11
14
|
import tenacity
|
|
12
15
|
import threading
|
|
@@ -39,6 +42,18 @@ threadsafety = 1
|
|
|
39
42
|
paramstyle = "pyformat"
|
|
40
43
|
|
|
41
44
|
|
|
45
|
+
def gen_user_agent_header():
|
|
46
|
+
try:
|
|
47
|
+
package_version = metadata.version("wherobots-python-dbapi")
|
|
48
|
+
except PackageNotFoundError:
|
|
49
|
+
package_version = "unknown"
|
|
50
|
+
python_version = platform.python_version()
|
|
51
|
+
system = platform.system().lower()
|
|
52
|
+
return {
|
|
53
|
+
"User-Agent": f"wherobots-python-dbapi/{package_version} os/{system} python/{python_version}"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
42
57
|
def connect(
|
|
43
58
|
host: str = DEFAULT_ENDPOINT,
|
|
44
59
|
token: str = None,
|
|
@@ -57,12 +72,14 @@ def connect(
|
|
|
57
72
|
if token and api_key:
|
|
58
73
|
raise ValueError("`token` and `api_key` can't be both provided")
|
|
59
74
|
|
|
60
|
-
headers =
|
|
75
|
+
headers = gen_user_agent_header()
|
|
61
76
|
if token:
|
|
62
77
|
headers["Authorization"] = f"Bearer {token}"
|
|
63
78
|
elif api_key:
|
|
64
79
|
headers["X-API-Key"] = api_key
|
|
65
80
|
|
|
81
|
+
logging.info(headers)
|
|
82
|
+
|
|
66
83
|
host = host or DEFAULT_ENDPOINT
|
|
67
84
|
runtime = runtime or DEFAULT_RUNTIME
|
|
68
85
|
region = region or DEFAULT_REGION
|
|
@@ -2,12 +2,12 @@ from enum import Enum
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class Runtime(Enum):
|
|
5
|
-
SEDONA = "
|
|
6
|
-
SAN_FRANCISCO = "
|
|
7
|
-
NEW_YORK = "
|
|
8
|
-
CAIRO = "
|
|
9
|
-
DELHI = "
|
|
10
|
-
TOKYO = "
|
|
5
|
+
SEDONA = "tiny"
|
|
6
|
+
SAN_FRANCISCO = "small"
|
|
7
|
+
NEW_YORK = "medium"
|
|
8
|
+
CAIRO = "large"
|
|
9
|
+
DELHI = "x-large"
|
|
10
|
+
TOKYO = "2x-large"
|
|
11
11
|
ATLANTIS = "4x-large"
|
|
12
12
|
|
|
13
13
|
NEW_YORK_HIMEM = "medium-himem"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|