crate 2.0.0.dev5__py3-none-any.whl → 2.1.0.dev0__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.
- crate/client/__init__.py +1 -1
- crate/client/connection.py +10 -1
- crate/client/http.py +29 -7
- {crate-2.0.0.dev5.dist-info → crate-2.1.0.dev0.dist-info}/METADATA +7 -7
- crate-2.1.0.dev0.dist-info/RECORD +17 -0
- {crate-2.0.0.dev5.dist-info → crate-2.1.0.dev0.dist-info}/WHEEL +1 -1
- crate-2.0.0.dev5.dist-info/RECORD +0 -17
- {crate-2.0.0.dev5.dist-info → crate-2.1.0.dev0.dist-info/licenses}/LICENSE +0 -0
- {crate-2.0.0.dev5.dist-info → crate-2.1.0.dev0.dist-info/licenses}/NOTICE +0 -0
- {crate-2.0.0.dev5.dist-info → crate-2.1.0.dev0.dist-info}/top_level.txt +0 -0
crate/client/__init__.py
CHANGED
crate/client/connection.py
CHANGED
@@ -18,8 +18,10 @@
|
|
18
18
|
# However, if you have executed another commercial license agreement
|
19
19
|
# with Crate these terms will supersede the license and you may use the
|
20
20
|
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
|
+
import json
|
21
22
|
|
22
23
|
from verlib2 import Version
|
24
|
+
from verlib2.packaging.version import InvalidVersion
|
23
25
|
|
24
26
|
from .blob import BlobContainer
|
25
27
|
from .cursor import Cursor
|
@@ -197,14 +199,21 @@ class Connection:
|
|
197
199
|
|
198
200
|
def _lowest_server_version(self):
|
199
201
|
lowest = None
|
202
|
+
server_count = len(self.client.active_servers)
|
203
|
+
connection_errors = []
|
200
204
|
for server in self.client.active_servers:
|
201
205
|
try:
|
202
206
|
_, _, version = self.client.server_infos(server)
|
203
207
|
version = Version(version)
|
204
|
-
except
|
208
|
+
except ConnectionError as ex:
|
209
|
+
connection_errors.append(ex)
|
210
|
+
continue
|
211
|
+
except (ValueError, InvalidVersion):
|
205
212
|
continue
|
206
213
|
if not lowest or version < lowest:
|
207
214
|
lowest = version
|
215
|
+
if connection_errors and len(connection_errors) == server_count:
|
216
|
+
raise ConnectionError(json.dumps(list(map(str, connection_errors))))
|
208
217
|
return lowest or Version("0.0.0")
|
209
218
|
|
210
219
|
def __repr__(self):
|
crate/client/http.py
CHANGED
@@ -20,6 +20,8 @@
|
|
20
20
|
# software solely pursuant to the terms of the relevant commercial agreement.
|
21
21
|
|
22
22
|
|
23
|
+
import calendar
|
24
|
+
import datetime as dt
|
23
25
|
import heapq
|
24
26
|
import io
|
25
27
|
import logging
|
@@ -84,19 +86,35 @@ def super_len(o):
|
|
84
86
|
return None
|
85
87
|
|
86
88
|
|
87
|
-
|
89
|
+
epoch_aware = dt.datetime(1970, 1, 1, tzinfo=dt.timezone.utc)
|
90
|
+
epoch_naive = dt.datetime(1970, 1, 1)
|
91
|
+
|
92
|
+
|
93
|
+
def json_encoder(obj: t.Any) -> t.Union[int, str]:
|
88
94
|
"""
|
89
95
|
Encoder function for orjson, with additional type support.
|
90
96
|
|
91
|
-
- Python's `Decimal` type
|
92
|
-
-
|
97
|
+
- Python's `Decimal` type will be serialized to `str`.
|
98
|
+
- Python's `dt.datetime` and `dt.date` types will be
|
99
|
+
serialized to `int` after converting to milliseconds
|
100
|
+
since epoch.
|
93
101
|
|
94
102
|
https://github.com/ijl/orjson#default
|
103
|
+
https://cratedb.com/docs/crate/reference/en/latest/general/ddl/data-types.html#type-timestamp
|
95
104
|
"""
|
96
105
|
if isinstance(obj, Decimal):
|
97
106
|
return str(obj)
|
98
|
-
|
99
|
-
|
107
|
+
if isinstance(obj, dt.datetime):
|
108
|
+
if obj.tzinfo is not None:
|
109
|
+
delta = obj - epoch_aware
|
110
|
+
else:
|
111
|
+
delta = obj - epoch_naive
|
112
|
+
return int(
|
113
|
+
delta.microseconds / 1000.0
|
114
|
+
+ (delta.seconds + delta.days * 24 * 3600) * 1000.0
|
115
|
+
)
|
116
|
+
if isinstance(obj, dt.date):
|
117
|
+
return calendar.timegm(obj.timetuple()) * 1000
|
100
118
|
raise TypeError
|
101
119
|
|
102
120
|
|
@@ -108,8 +126,12 @@ def json_dumps(obj: t.Any) -> bytes:
|
|
108
126
|
"""
|
109
127
|
return orjson.dumps(
|
110
128
|
obj,
|
111
|
-
default=
|
112
|
-
option=(
|
129
|
+
default=json_encoder,
|
130
|
+
option=(
|
131
|
+
orjson.OPT_PASSTHROUGH_DATETIME
|
132
|
+
| orjson.OPT_NON_STR_KEYS
|
133
|
+
| orjson.OPT_SERIALIZE_NUMPY
|
134
|
+
),
|
113
135
|
)
|
114
136
|
|
115
137
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: crate
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.1.0.dev0
|
4
4
|
Summary: CrateDB Python Client
|
5
5
|
Home-page: https://github.com/crate/crate-python
|
6
6
|
Author: Crate.io
|
@@ -39,15 +39,14 @@ Provides-Extra: test
|
|
39
39
|
Requires-Dist: backports.zoneinfo<1; python_version < "3.9" and extra == "test"
|
40
40
|
Requires-Dist: certifi; extra == "test"
|
41
41
|
Requires-Dist: createcoverage<2,>=1; extra == "test"
|
42
|
-
Requires-Dist: mypy<1.
|
43
|
-
Requires-Dist: poethepoet<
|
44
|
-
Requires-Dist: ruff<0.
|
42
|
+
Requires-Dist: mypy<1.16; extra == "test"
|
43
|
+
Requires-Dist: poethepoet<1; extra == "test"
|
44
|
+
Requires-Dist: ruff<0.12; extra == "test"
|
45
45
|
Requires-Dist: stopit<2,>=1.1.2; extra == "test"
|
46
|
-
Requires-Dist: tox<5,>=3; extra == "test"
|
47
46
|
Requires-Dist: pytz; extra == "test"
|
48
47
|
Requires-Dist: zc.customdoctests<2,>=1.0.1; extra == "test"
|
49
48
|
Requires-Dist: zope.testing<6,>=4; extra == "test"
|
50
|
-
Requires-Dist: zope.testrunner<
|
49
|
+
Requires-Dist: zope.testrunner<8,>=5; extra == "test"
|
51
50
|
Dynamic: author
|
52
51
|
Dynamic: author-email
|
53
52
|
Dynamic: classifier
|
@@ -56,6 +55,7 @@ Dynamic: description-content-type
|
|
56
55
|
Dynamic: home-page
|
57
56
|
Dynamic: keywords
|
58
57
|
Dynamic: license
|
58
|
+
Dynamic: license-file
|
59
59
|
Dynamic: platform
|
60
60
|
Dynamic: provides-extra
|
61
61
|
Dynamic: requires-dist
|
@@ -0,0 +1,17 @@
|
|
1
|
+
crate/client/__init__.py,sha256=wwIu-g-AQn0SiBYFAo3-sOkejI_c7uT9rn-Zd1ddySo,1349
|
2
|
+
crate/client/_pep440.py,sha256=iwY5wopxbgbwsT0ImANrwN3V_ZYQHhSr7lEdVT5dQRM,42
|
3
|
+
crate/client/blob.py,sha256=aMo6ZNHGT3Zq_yR3gcpd3CKrJvfqUAhExhKtHUwC5Io,3460
|
4
|
+
crate/client/connection.py,sha256=uA-r_HLo4mjbouYirV0xIF6rp9GAtK-PtAJlyNxpvHA,8514
|
5
|
+
crate/client/converter.py,sha256=Qci0MNcpz1jAnjquG8Ld9LI84_iHVInrv4HMb8r5zzg,4313
|
6
|
+
crate/client/cursor.py,sha256=Mlk-TVLzM4zSSr7GxcHK4Mjbt1KQeMfNFNrPBtGjk-c,10741
|
7
|
+
crate/client/exceptions.py,sha256=wMyJmOB3RP5kuPeW9f0fEb-1AKZcGSTyIGvN0HqpqUw,2557
|
8
|
+
crate/client/http.py,sha256=wNTlFOwYv9R4dMWvaZ7b-U-uzUwLNJB7pknwiE_QGkE,23270
|
9
|
+
crate/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
+
crate/testing/layer.py,sha256=jvHRWTRE4Zal211UO0HWPFcbprAcaGB3WyAUDR7BKFQ,13376
|
11
|
+
crate/testing/util.py,sha256=BPEZ8DavXwyOTCmOQnP5QjQlapEw3harzKK4w2HOTA4,3264
|
12
|
+
crate-2.1.0.dev0.dist-info/licenses/LICENSE,sha256=s_w3FXmAYQuatqsgvyYLnGyC_13KOqp3W1DUEXO9RpY,10175
|
13
|
+
crate-2.1.0.dev0.dist-info/licenses/NOTICE,sha256=jfWOHkoZKjNATGXMfgpMJdL38ki_ZZTgR6M9CUUJxrM,1159
|
14
|
+
crate-2.1.0.dev0.dist-info/METADATA,sha256=xAe-f67sKCkfH3YyY6HmDbeQJ8a2Of_4KFRKeuKxPhg,5632
|
15
|
+
crate-2.1.0.dev0.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
16
|
+
crate-2.1.0.dev0.dist-info/top_level.txt,sha256=2wP2HlpxdhgTLMl9ipi168xkm6FMq9_2bf0xGGxF_OI,6
|
17
|
+
crate-2.1.0.dev0.dist-info/RECORD,,
|
@@ -1,17 +0,0 @@
|
|
1
|
-
crate/client/__init__.py,sha256=ApP2LvuWsycIceLILaXsUgyFR96CcOx7C7hI5OXEdtc,1349
|
2
|
-
crate/client/_pep440.py,sha256=iwY5wopxbgbwsT0ImANrwN3V_ZYQHhSr7lEdVT5dQRM,42
|
3
|
-
crate/client/blob.py,sha256=aMo6ZNHGT3Zq_yR3gcpd3CKrJvfqUAhExhKtHUwC5Io,3460
|
4
|
-
crate/client/connection.py,sha256=80v9_--YilDAaIQpejf3G_TWGz9iwUkixwHAL66sDm0,8098
|
5
|
-
crate/client/converter.py,sha256=Qci0MNcpz1jAnjquG8Ld9LI84_iHVInrv4HMb8r5zzg,4313
|
6
|
-
crate/client/cursor.py,sha256=Mlk-TVLzM4zSSr7GxcHK4Mjbt1KQeMfNFNrPBtGjk-c,10741
|
7
|
-
crate/client/exceptions.py,sha256=wMyJmOB3RP5kuPeW9f0fEb-1AKZcGSTyIGvN0HqpqUw,2557
|
8
|
-
crate/client/http.py,sha256=b_EVzChq6FGQg4tNc-3fheUas9mybQJI4aMHKYVpGEU,22513
|
9
|
-
crate/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
-
crate/testing/layer.py,sha256=jvHRWTRE4Zal211UO0HWPFcbprAcaGB3WyAUDR7BKFQ,13376
|
11
|
-
crate/testing/util.py,sha256=BPEZ8DavXwyOTCmOQnP5QjQlapEw3harzKK4w2HOTA4,3264
|
12
|
-
crate-2.0.0.dev5.dist-info/LICENSE,sha256=s_w3FXmAYQuatqsgvyYLnGyC_13KOqp3W1DUEXO9RpY,10175
|
13
|
-
crate-2.0.0.dev5.dist-info/METADATA,sha256=GpJuX0mupTBanwtxvK3MJhMYRAyhdnhl48NtkeCPNsw,5655
|
14
|
-
crate-2.0.0.dev5.dist-info/NOTICE,sha256=jfWOHkoZKjNATGXMfgpMJdL38ki_ZZTgR6M9CUUJxrM,1159
|
15
|
-
crate-2.0.0.dev5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
16
|
-
crate-2.0.0.dev5.dist-info/top_level.txt,sha256=2wP2HlpxdhgTLMl9ipi168xkm6FMq9_2bf0xGGxF_OI,6
|
17
|
-
crate-2.0.0.dev5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|