crate 2.0.0.dev1__py3-none-any.whl → 2.0.0.dev3__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
crate/client/__init__.py CHANGED
@@ -29,7 +29,7 @@ __all__ = [
29
29
 
30
30
  # version string read from setup.py using a regex. Take care not to break the
31
31
  # regex!
32
- __version__ = "2.0.0.dev1"
32
+ __version__ = "2.0.0.dev3"
33
33
 
34
34
  # codeql[py/unused-global-variable]
35
35
  apilevel = "2.0"
crate/client/http.py CHANGED
@@ -20,7 +20,6 @@
20
20
  # software solely pursuant to the terms of the relevant commercial agreement.
21
21
 
22
22
 
23
- import calendar
24
23
  import heapq
25
24
  import io
26
25
  import logging
@@ -30,11 +29,9 @@ import socket
30
29
  import ssl
31
30
  import threading
32
31
  from base64 import b64encode
33
- from datetime import date, datetime, timezone
34
32
  from decimal import Decimal
35
33
  from time import time
36
34
  from urllib.parse import urlparse
37
- from uuid import UUID
38
35
 
39
36
  import orjson
40
37
  import urllib3
@@ -86,33 +83,25 @@ def super_len(o):
86
83
  return None
87
84
 
88
85
 
89
- epoch_aware = datetime(1970, 1, 1, tzinfo=timezone.utc)
90
- epoch_naive = datetime(1970, 1, 1)
91
-
92
-
93
86
  def cratedb_json_encoder(obj):
94
87
  """
95
88
  Encoder function for orjson.
96
89
 
97
90
  https://github.com/ijl/orjson#default
98
- https://github.com/ijl/orjson#opt_passthrough_datetime
99
91
  """
100
- if isinstance(obj, (Decimal, UUID)):
92
+ if isinstance(obj, (Decimal,)):
101
93
  return str(obj)
102
- if isinstance(obj, datetime):
103
- if obj.tzinfo is not None:
104
- delta = obj - epoch_aware
105
- else:
106
- delta = obj - epoch_naive
107
- return int(
108
- delta.microseconds / 1000.0
109
- + (delta.seconds + delta.days * 24 * 3600) * 1000.0
110
- )
111
- if isinstance(obj, date):
112
- return calendar.timegm(obj.timetuple()) * 1000
113
94
  return obj
114
95
 
115
96
 
97
+ def json_dumps(obj):
98
+ return orjson.dumps(
99
+ obj,
100
+ default=cratedb_json_encoder,
101
+ option=orjson.OPT_SERIALIZE_NUMPY,
102
+ )
103
+
104
+
116
105
  class Server:
117
106
  def __init__(self, server, **pool_kw):
118
107
  socket_options = _get_socket_opts(
@@ -340,11 +329,7 @@ def _create_sql_payload(stmt, args, bulk_args):
340
329
  data["args"] = args
341
330
  if bulk_args:
342
331
  data["bulk_args"] = bulk_args
343
- return orjson.dumps(
344
- data,
345
- default=cratedb_json_encoder,
346
- option=(orjson.OPT_PASSTHROUGH_DATETIME | orjson.OPT_SERIALIZE_NUMPY),
347
- )
332
+ return json_dumps(data)
348
333
 
349
334
 
350
335
  def _get_socket_opts(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: crate
3
- Version: 2.0.0.dev1
3
+ Version: 2.0.0.dev3
4
4
  Summary: CrateDB Python Client
5
5
  Home-page: https://github.com/crate/crate-python
6
6
  Author: Crate.io
@@ -1,17 +1,17 @@
1
- crate/client/__init__.py,sha256=7f-j_r1BGiuvnVPyiHs2aO7ijiUlisg5l-7MxmtrclE,1349
1
+ crate/client/__init__.py,sha256=KJxfw5bFsK_B0BEj1E74dFBMWuDAsFfpA2Y8Gej43AM,1349
2
2
  crate/client/_pep440.py,sha256=iwY5wopxbgbwsT0ImANrwN3V_ZYQHhSr7lEdVT5dQRM,42
3
3
  crate/client/blob.py,sha256=aMo6ZNHGT3Zq_yR3gcpd3CKrJvfqUAhExhKtHUwC5Io,3460
4
4
  crate/client/connection.py,sha256=80v9_--YilDAaIQpejf3G_TWGz9iwUkixwHAL66sDm0,8098
5
5
  crate/client/converter.py,sha256=Qci0MNcpz1jAnjquG8Ld9LI84_iHVInrv4HMb8r5zzg,4313
6
6
  crate/client/cursor.py,sha256=Mlk-TVLzM4zSSr7GxcHK4Mjbt1KQeMfNFNrPBtGjk-c,10741
7
7
  crate/client/exceptions.py,sha256=wMyJmOB3RP5kuPeW9f0fEb-1AKZcGSTyIGvN0HqpqUw,2557
8
- crate/client/http.py,sha256=2FnY8vQ0foEmUa2DjTHb649S-u4q5gCWS3vyDe2GfjU,22735
8
+ crate/client/http.py,sha256=MnrMZ5JIyghAgp7QboREHpWwV3NW9gigFAUzo6Wd8Eg,22130
9
9
  crate/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  crate/testing/layer.py,sha256=jvHRWTRE4Zal211UO0HWPFcbprAcaGB3WyAUDR7BKFQ,13376
11
11
  crate/testing/util.py,sha256=BPEZ8DavXwyOTCmOQnP5QjQlapEw3harzKK4w2HOTA4,3264
12
- crate-2.0.0.dev1.dist-info/LICENSE,sha256=s_w3FXmAYQuatqsgvyYLnGyC_13KOqp3W1DUEXO9RpY,10175
13
- crate-2.0.0.dev1.dist-info/METADATA,sha256=9H2jwOBKvVSFWvR2adKUbn3YYStBDa1OQOeX05Zp464,5655
14
- crate-2.0.0.dev1.dist-info/NOTICE,sha256=jfWOHkoZKjNATGXMfgpMJdL38ki_ZZTgR6M9CUUJxrM,1159
15
- crate-2.0.0.dev1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
16
- crate-2.0.0.dev1.dist-info/top_level.txt,sha256=2wP2HlpxdhgTLMl9ipi168xkm6FMq9_2bf0xGGxF_OI,6
17
- crate-2.0.0.dev1.dist-info/RECORD,,
12
+ crate-2.0.0.dev3.dist-info/LICENSE,sha256=s_w3FXmAYQuatqsgvyYLnGyC_13KOqp3W1DUEXO9RpY,10175
13
+ crate-2.0.0.dev3.dist-info/METADATA,sha256=FRLfH3m7xC2wgcs0O1b2tRsDcDqCyviODEkrfJj0YPw,5655
14
+ crate-2.0.0.dev3.dist-info/NOTICE,sha256=jfWOHkoZKjNATGXMfgpMJdL38ki_ZZTgR6M9CUUJxrM,1159
15
+ crate-2.0.0.dev3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
16
+ crate-2.0.0.dev3.dist-info/top_level.txt,sha256=2wP2HlpxdhgTLMl9ipi168xkm6FMq9_2bf0xGGxF_OI,6
17
+ crate-2.0.0.dev3.dist-info/RECORD,,