singlestoredb 1.0.4__cp38-abi3-win32.whl → 1.1.0__cp38-abi3-win32.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.
Potentially problematic release.
This version of singlestoredb might be problematic. Click here for more details.
- _singlestoredb_accel.pyd +0 -0
- singlestoredb/__init__.py +1 -1
- singlestoredb/config.py +125 -0
- singlestoredb/functions/dtypes.py +5 -198
- singlestoredb/functions/ext/__init__.py +0 -1
- singlestoredb/functions/ext/asgi.py +665 -153
- singlestoredb/functions/ext/json.py +2 -2
- singlestoredb/functions/ext/mmap.py +174 -67
- singlestoredb/functions/ext/rowdat_1.py +2 -2
- singlestoredb/functions/ext/utils.py +169 -0
- singlestoredb/fusion/handler.py +109 -9
- singlestoredb/fusion/handlers/stage.py +150 -0
- singlestoredb/fusion/handlers/workspace.py +265 -4
- singlestoredb/fusion/registry.py +69 -1
- singlestoredb/http/connection.py +40 -2
- singlestoredb/mysql/connection.py +69 -0
- singlestoredb/mysql/cursors.py +176 -4
- singlestoredb/tests/test.sql +210 -0
- singlestoredb/tests/test_connection.py +1408 -0
- singlestoredb/tests/test_ext_func.py +2 -2
- singlestoredb/tests/test_ext_func_data.py +1 -1
- singlestoredb/utils/dtypes.py +205 -0
- singlestoredb/utils/results.py +367 -14
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.1.0.dist-info}/METADATA +2 -1
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.1.0.dist-info}/RECORD +29 -27
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.1.0.dist-info}/LICENSE +0 -0
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.1.0.dist-info}/WHEEL +0 -0
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.1.0.dist-info}/entry_points.txt +0 -0
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.1.0.dist-info}/top_level.txt +0 -0
singlestoredb/utils/results.py
CHANGED
|
@@ -11,22 +11,51 @@ from typing import Optional
|
|
|
11
11
|
from typing import Tuple
|
|
12
12
|
from typing import Union
|
|
13
13
|
|
|
14
|
+
from .dtypes import NUMPY_TYPE_MAP
|
|
15
|
+
from .dtypes import POLARS_TYPE_MAP
|
|
16
|
+
from .dtypes import PYARROW_TYPE_MAP
|
|
17
|
+
|
|
18
|
+
UNSIGNED_FLAG = 32
|
|
19
|
+
BINARY_FLAG = 128
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
has_numpy = True
|
|
23
|
+
import numpy as np
|
|
24
|
+
except ImportError:
|
|
25
|
+
has_numpy = False
|
|
26
|
+
|
|
14
27
|
try:
|
|
15
28
|
has_pandas = True
|
|
16
|
-
|
|
29
|
+
import pandas as pd
|
|
17
30
|
except ImportError:
|
|
18
31
|
has_pandas = False
|
|
19
|
-
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
has_polars = True
|
|
35
|
+
import polars as pl
|
|
36
|
+
except ImportError:
|
|
37
|
+
has_polars = False
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
has_pyarrow = True
|
|
41
|
+
import pyarrow as pa
|
|
42
|
+
except ImportError:
|
|
43
|
+
has_pyarrow = False
|
|
20
44
|
|
|
21
45
|
DBAPIResult = Union[List[Tuple[Any, ...]], Tuple[Any, ...]]
|
|
22
|
-
OneResult = Union[
|
|
23
|
-
|
|
46
|
+
OneResult = Union[
|
|
47
|
+
Tuple[Any, ...], Dict[str, Any],
|
|
48
|
+
'np.ndarray', 'pd.DataFrame', 'pl.DataFrame', 'pa.Table',
|
|
49
|
+
]
|
|
50
|
+
ManyResult = Union[
|
|
51
|
+
List[Tuple[Any, ...]], List[Dict[str, Any]],
|
|
52
|
+
'np.ndarray', 'pd.DataFrame', 'pl.DataFrame', 'pa.Table',
|
|
53
|
+
]
|
|
24
54
|
Result = Union[OneResult, ManyResult]
|
|
25
55
|
|
|
26
56
|
|
|
27
57
|
class Description(NamedTuple):
|
|
28
58
|
"""Column definition."""
|
|
29
|
-
|
|
30
59
|
name: str
|
|
31
60
|
type_code: int
|
|
32
61
|
display_size: Optional[int]
|
|
@@ -38,13 +67,174 @@ class Description(NamedTuple):
|
|
|
38
67
|
charset: Optional[int]
|
|
39
68
|
|
|
40
69
|
|
|
41
|
-
|
|
70
|
+
if has_numpy:
|
|
71
|
+
# If an int column is nullable, we need to use floats rather than
|
|
72
|
+
# ints for numpy and pandas.
|
|
73
|
+
NUMPY_TYPE_MAP_CAST_FLOAT = NUMPY_TYPE_MAP.copy()
|
|
74
|
+
NUMPY_TYPE_MAP_CAST_FLOAT.update({
|
|
75
|
+
1: np.float32, # Tiny
|
|
76
|
+
-1: np.float32, # Unsigned Tiny
|
|
77
|
+
2: np.float32, # Short
|
|
78
|
+
-2: np.float32, # Unsigned Short
|
|
79
|
+
3: np.float64, # Long
|
|
80
|
+
-3: np.float64, # Unsigned Long
|
|
81
|
+
8: np.float64, # LongLong
|
|
82
|
+
-8: np.float64, # Unsigned LongLong
|
|
83
|
+
9: np.float64, # Int24
|
|
84
|
+
-9: np.float64, # Unsigned Int24
|
|
85
|
+
13: np.float64, # Year
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
if has_polars:
|
|
89
|
+
# Remap date/times to strings; let polars do the parsing
|
|
90
|
+
POLARS_TYPE_MAP = POLARS_TYPE_MAP.copy()
|
|
91
|
+
POLARS_TYPE_MAP.update({
|
|
92
|
+
7: pl.Utf8,
|
|
93
|
+
10: pl.Utf8,
|
|
94
|
+
12: pl.Utf8,
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
INT_TYPES = set([1, 2, 3, 8, 9])
|
|
99
|
+
CHAR_TYPES = set([15, 249, 250, 251, 252, 253, 254])
|
|
100
|
+
DECIMAL_TYPES = set([0, 246])
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def signed(desc: Description) -> int:
|
|
104
|
+
if ((desc.flags or 0) & UNSIGNED_FLAG and desc.type_code in INT_TYPES) or \
|
|
105
|
+
(desc.charset == 63 and desc.type_code in CHAR_TYPES):
|
|
106
|
+
return -desc.type_code
|
|
107
|
+
return desc.type_code
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _description_to_numpy_schema(desc: List[Description]) -> Dict[str, Any]:
|
|
111
|
+
"""Convert description to numpy array schema info."""
|
|
112
|
+
if has_numpy:
|
|
113
|
+
return dict(
|
|
114
|
+
dtype=[
|
|
115
|
+
(
|
|
116
|
+
x.name,
|
|
117
|
+
NUMPY_TYPE_MAP_CAST_FLOAT[signed(x)]
|
|
118
|
+
if x.null_ok else NUMPY_TYPE_MAP[signed(x)],
|
|
119
|
+
)
|
|
120
|
+
for x in desc
|
|
121
|
+
],
|
|
122
|
+
)
|
|
123
|
+
return {}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _description_to_pandas_schema(desc: List[Description]) -> Dict[str, Any]:
|
|
127
|
+
"""Convert description to pandas DataFrame schema info."""
|
|
128
|
+
if has_pandas:
|
|
129
|
+
return dict(columns=[x.name for x in desc])
|
|
130
|
+
return {}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def _decimalize_polars(desc: Description) -> 'pl.Decimal':
|
|
134
|
+
return pl.Decimal(desc.precision or 10, desc.scale or 0)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _description_to_polars_schema(desc: List[Description]) -> Dict[str, Any]:
|
|
138
|
+
"""Convert description to polars DataFrame schema info."""
|
|
139
|
+
if has_polars:
|
|
140
|
+
with_columns = {}
|
|
141
|
+
for x in desc:
|
|
142
|
+
if x.type_code in [7, 12]:
|
|
143
|
+
if x.scale == 6:
|
|
144
|
+
with_columns[x.name] = pl.col(x.name).str.to_datetime(
|
|
145
|
+
'%Y-%m-%d %H:%M:%S.%6f', time_unit='us',
|
|
146
|
+
)
|
|
147
|
+
else:
|
|
148
|
+
with_columns[x.name] = pl.col(x.name).str.to_datetime(
|
|
149
|
+
'%Y-%m-%d %H:%M:%S', time_unit='us',
|
|
150
|
+
)
|
|
151
|
+
elif x.type_code == 10:
|
|
152
|
+
with_columns[x.name] = pl.col(x.name).str.to_date('%Y-%m-%d')
|
|
153
|
+
|
|
154
|
+
return dict(
|
|
155
|
+
schema=dict(
|
|
156
|
+
schema=[
|
|
157
|
+
(
|
|
158
|
+
x.name, _decimalize_polars(x)
|
|
159
|
+
if x.type_code in DECIMAL_TYPES else POLARS_TYPE_MAP[signed(x)],
|
|
160
|
+
)
|
|
161
|
+
for x in desc
|
|
162
|
+
],
|
|
163
|
+
),
|
|
164
|
+
with_columns=with_columns,
|
|
165
|
+
)
|
|
166
|
+
return {}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _decimalize_arrow(desc: Description) -> 'pa.Decimal128':
|
|
170
|
+
return pa.decimal128(desc.precision or 10, desc.scale or 0)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _description_to_arrow_schema(desc: List[Description]) -> Dict[str, Any]:
|
|
174
|
+
"""Convert description to Arrow Table schema info."""
|
|
175
|
+
if has_pyarrow:
|
|
176
|
+
return dict(
|
|
177
|
+
schema=pa.schema([
|
|
178
|
+
(
|
|
179
|
+
x.name, _decimalize_arrow(x)
|
|
180
|
+
if x.type_code in DECIMAL_TYPES else PYARROW_TYPE_MAP[signed(x)],
|
|
181
|
+
)
|
|
182
|
+
for x in desc
|
|
183
|
+
]),
|
|
184
|
+
)
|
|
185
|
+
return {}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def results_to_numpy(
|
|
189
|
+
desc: List[Description],
|
|
190
|
+
res: Optional[DBAPIResult],
|
|
191
|
+
single: Optional[bool] = False,
|
|
192
|
+
schema: Optional[Dict[str, Any]] = None,
|
|
193
|
+
) -> Optional[Result]:
|
|
194
|
+
"""
|
|
195
|
+
Convert results to numpy.
|
|
196
|
+
|
|
197
|
+
Parameters
|
|
198
|
+
----------
|
|
199
|
+
desc : list of Descriptions
|
|
200
|
+
The column metadata
|
|
201
|
+
res : tuple or list of tuples
|
|
202
|
+
The query results
|
|
203
|
+
single : bool, optional
|
|
204
|
+
Is this a single result (i.e., from `fetchone`)?
|
|
205
|
+
schema : Dict[str, Any], optional
|
|
206
|
+
Cached schema for current output format
|
|
207
|
+
|
|
208
|
+
Returns
|
|
209
|
+
-------
|
|
210
|
+
numpy.array
|
|
211
|
+
If `numpy` is available
|
|
212
|
+
tuple or list of tuples
|
|
213
|
+
If `numpy` is not available
|
|
214
|
+
|
|
215
|
+
"""
|
|
216
|
+
if not res:
|
|
217
|
+
return res
|
|
218
|
+
if has_numpy:
|
|
219
|
+
schema = _description_to_numpy_schema(desc) if schema is None else schema
|
|
220
|
+
if single:
|
|
221
|
+
return np.array([res], **schema)
|
|
222
|
+
return np.array(list(res), **schema)
|
|
223
|
+
warnings.warn(
|
|
224
|
+
'numpy is not available; unable to convert to array',
|
|
225
|
+
RuntimeWarning,
|
|
226
|
+
)
|
|
227
|
+
return res
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def results_to_pandas(
|
|
42
231
|
desc: List[Description],
|
|
43
232
|
res: Optional[DBAPIResult],
|
|
44
233
|
single: Optional[bool] = False,
|
|
234
|
+
schema: Optional[Dict[str, Any]] = None,
|
|
45
235
|
) -> Optional[Result]:
|
|
46
236
|
"""
|
|
47
|
-
Convert results to
|
|
237
|
+
Convert results to pandas.
|
|
48
238
|
|
|
49
239
|
Parameters
|
|
50
240
|
----------
|
|
@@ -54,6 +244,8 @@ def results_to_dataframe(
|
|
|
54
244
|
The query results
|
|
55
245
|
single : bool, optional
|
|
56
246
|
Is this a single result (i.e., from `fetchone`)?
|
|
247
|
+
schema : Dict[str, Any], optional
|
|
248
|
+
Cached schema for current output format
|
|
57
249
|
|
|
58
250
|
Returns
|
|
59
251
|
-------
|
|
@@ -66,10 +258,8 @@ def results_to_dataframe(
|
|
|
66
258
|
if not res:
|
|
67
259
|
return res
|
|
68
260
|
if has_pandas:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return DataFrame([res], columns=columns)
|
|
72
|
-
return DataFrame(res, columns=columns)
|
|
261
|
+
schema = _description_to_pandas_schema(desc) if schema is None else schema
|
|
262
|
+
return pd.DataFrame(results_to_numpy(desc, res, single=single, schema=schema))
|
|
73
263
|
warnings.warn(
|
|
74
264
|
'pandas is not available; unable to convert to DataFrame',
|
|
75
265
|
RuntimeWarning,
|
|
@@ -77,10 +267,107 @@ def results_to_dataframe(
|
|
|
77
267
|
return res
|
|
78
268
|
|
|
79
269
|
|
|
270
|
+
def results_to_polars(
|
|
271
|
+
desc: List[Description],
|
|
272
|
+
res: Optional[DBAPIResult],
|
|
273
|
+
single: Optional[bool] = False,
|
|
274
|
+
schema: Optional[Dict[str, Any]] = None,
|
|
275
|
+
) -> Optional[Result]:
|
|
276
|
+
"""
|
|
277
|
+
Convert results to polars.
|
|
278
|
+
|
|
279
|
+
Parameters
|
|
280
|
+
----------
|
|
281
|
+
desc : list of Descriptions
|
|
282
|
+
The column metadata
|
|
283
|
+
res : tuple or list of tuples
|
|
284
|
+
The query results
|
|
285
|
+
single : bool, optional
|
|
286
|
+
Is this a single result (i.e., from `fetchone`)?
|
|
287
|
+
schema : Dict[str, Any], optional
|
|
288
|
+
Cached schema for current output format
|
|
289
|
+
|
|
290
|
+
Returns
|
|
291
|
+
-------
|
|
292
|
+
DataFrame
|
|
293
|
+
If `polars` is available
|
|
294
|
+
tuple or list of tuples
|
|
295
|
+
If `polars` is not available
|
|
296
|
+
|
|
297
|
+
"""
|
|
298
|
+
if not res:
|
|
299
|
+
return res
|
|
300
|
+
if has_polars:
|
|
301
|
+
schema = _description_to_polars_schema(desc) if schema is None else schema
|
|
302
|
+
if single:
|
|
303
|
+
out = pl.DataFrame([res], **schema.get('schema', {}))
|
|
304
|
+
else:
|
|
305
|
+
out = pl.DataFrame(res, **schema.get('schema', {}))
|
|
306
|
+
with_columns = schema.get('with_columns')
|
|
307
|
+
if with_columns:
|
|
308
|
+
return out.with_columns(**with_columns)
|
|
309
|
+
return out
|
|
310
|
+
warnings.warn(
|
|
311
|
+
'polars is not available; unable to convert to DataFrame',
|
|
312
|
+
RuntimeWarning,
|
|
313
|
+
)
|
|
314
|
+
return res
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def results_to_arrow(
|
|
318
|
+
desc: List[Description],
|
|
319
|
+
res: Optional[DBAPIResult],
|
|
320
|
+
single: Optional[bool] = False,
|
|
321
|
+
schema: Optional[Dict[str, Any]] = None,
|
|
322
|
+
) -> Optional[Result]:
|
|
323
|
+
"""
|
|
324
|
+
Convert results to Arrow.
|
|
325
|
+
|
|
326
|
+
Parameters
|
|
327
|
+
----------
|
|
328
|
+
desc : list of Descriptions
|
|
329
|
+
The column metadata
|
|
330
|
+
res : tuple or list of tuples
|
|
331
|
+
The query results
|
|
332
|
+
single : bool, optional
|
|
333
|
+
Is this a single result (i.e., from `fetchone`)?
|
|
334
|
+
schema : Dict[str, Any], optional
|
|
335
|
+
Cached schema for current output format
|
|
336
|
+
|
|
337
|
+
Returns
|
|
338
|
+
-------
|
|
339
|
+
Table
|
|
340
|
+
If `pyarrow` is available
|
|
341
|
+
tuple or list of tuples
|
|
342
|
+
If `pyarrow` is not available
|
|
343
|
+
|
|
344
|
+
"""
|
|
345
|
+
if not res:
|
|
346
|
+
return res
|
|
347
|
+
if has_pyarrow:
|
|
348
|
+
names = [x[0] for x in desc]
|
|
349
|
+
schema = _description_to_arrow_schema(desc) if schema is None else schema
|
|
350
|
+
if single:
|
|
351
|
+
if isinstance(res, dict):
|
|
352
|
+
return pa.Table.from_pylist([res], **schema)
|
|
353
|
+
else:
|
|
354
|
+
return pa.Table.from_pylist([dict(zip(names, res))], **schema)
|
|
355
|
+
if isinstance(res[0], dict):
|
|
356
|
+
return pa.Table.from_pylist(res, **schema)
|
|
357
|
+
else:
|
|
358
|
+
return pa.Table.from_pylist([dict(zip(names, x)) for x in res], **schema)
|
|
359
|
+
warnings.warn(
|
|
360
|
+
'pyarrow is not available; unable to convert to Table',
|
|
361
|
+
RuntimeWarning,
|
|
362
|
+
)
|
|
363
|
+
return res
|
|
364
|
+
|
|
365
|
+
|
|
80
366
|
def results_to_namedtuple(
|
|
81
367
|
desc: List[Description],
|
|
82
368
|
res: Optional[DBAPIResult],
|
|
83
369
|
single: Optional[bool] = False,
|
|
370
|
+
schema: Optional[Dict[str, Any]] = None,
|
|
84
371
|
) -> Optional[Result]:
|
|
85
372
|
"""
|
|
86
373
|
Convert results to namedtuples.
|
|
@@ -93,6 +380,8 @@ def results_to_namedtuple(
|
|
|
93
380
|
The query results
|
|
94
381
|
single : bool, optional
|
|
95
382
|
Is this a single result (i.e., from `fetchone`)?
|
|
383
|
+
schema : Dict[str, Any], optional
|
|
384
|
+
Cached schema for current output format
|
|
96
385
|
|
|
97
386
|
Returns
|
|
98
387
|
-------
|
|
@@ -118,6 +407,7 @@ def results_to_dict(
|
|
|
118
407
|
desc: List[Description],
|
|
119
408
|
res: Optional[DBAPIResult],
|
|
120
409
|
single: Optional[bool] = False,
|
|
410
|
+
schema: Optional[Dict[str, Any]] = None,
|
|
121
411
|
) -> Optional[Result]:
|
|
122
412
|
"""
|
|
123
413
|
Convert results to dicts.
|
|
@@ -130,6 +420,8 @@ def results_to_dict(
|
|
|
130
420
|
The query results
|
|
131
421
|
single : bool, optional
|
|
132
422
|
Is this a single result (i.e., from `fetchone`)?
|
|
423
|
+
schema : Dict[str, Any], optional
|
|
424
|
+
Cached schema for current output format
|
|
133
425
|
|
|
134
426
|
Returns
|
|
135
427
|
-------
|
|
@@ -151,6 +443,7 @@ def results_to_tuple(
|
|
|
151
443
|
desc: List[Description],
|
|
152
444
|
res: Optional[DBAPIResult],
|
|
153
445
|
single: Optional[bool] = False,
|
|
446
|
+
schema: Optional[Dict[str, Any]] = None,
|
|
154
447
|
) -> Optional[Result]:
|
|
155
448
|
"""
|
|
156
449
|
Convert results to tuples.
|
|
@@ -163,6 +456,8 @@ def results_to_tuple(
|
|
|
163
456
|
The query results
|
|
164
457
|
single : bool, optional
|
|
165
458
|
Is this a single result (i.e., from `fetchone`)?
|
|
459
|
+
schema : Dict[str, Any], optional
|
|
460
|
+
Cached schema for current output format
|
|
166
461
|
|
|
167
462
|
Returns
|
|
168
463
|
-------
|
|
@@ -183,9 +478,16 @@ def results_to_tuple(
|
|
|
183
478
|
return [tuple(x) for x in res]
|
|
184
479
|
|
|
185
480
|
|
|
481
|
+
def _no_schema(desc: List[Description]) -> Optional[Dict[str, Any]]:
|
|
482
|
+
return {}
|
|
483
|
+
|
|
484
|
+
|
|
186
485
|
_converters: Dict[
|
|
187
486
|
str, Callable[
|
|
188
|
-
[
|
|
487
|
+
[
|
|
488
|
+
List[Description], Optional[DBAPIResult],
|
|
489
|
+
Optional[bool], Optional[Dict[str, Any]],
|
|
490
|
+
],
|
|
189
491
|
Optional[Result],
|
|
190
492
|
],
|
|
191
493
|
] = {
|
|
@@ -195,7 +497,29 @@ _converters: Dict[
|
|
|
195
497
|
'namedtuples': results_to_namedtuple,
|
|
196
498
|
'dict': results_to_dict,
|
|
197
499
|
'dicts': results_to_dict,
|
|
198
|
-
'
|
|
500
|
+
'numpy': results_to_numpy,
|
|
501
|
+
'pandas': results_to_pandas,
|
|
502
|
+
'polars': results_to_polars,
|
|
503
|
+
'arrow': results_to_arrow,
|
|
504
|
+
'pyarrow': results_to_arrow,
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
_schema_converters: Dict[
|
|
508
|
+
str, Callable[
|
|
509
|
+
[List[Description]], Optional[Dict[str, Any]],
|
|
510
|
+
],
|
|
511
|
+
] = {
|
|
512
|
+
'tuple': _no_schema,
|
|
513
|
+
'tuples': _no_schema,
|
|
514
|
+
'namedtuple': _no_schema,
|
|
515
|
+
'namedtuples': _no_schema,
|
|
516
|
+
'dict': _no_schema,
|
|
517
|
+
'dicts': _no_schema,
|
|
518
|
+
'numpy': _description_to_numpy_schema,
|
|
519
|
+
'pandas': _description_to_numpy_schema,
|
|
520
|
+
'polars': _description_to_polars_schema,
|
|
521
|
+
'arrow': _description_to_arrow_schema,
|
|
522
|
+
'pyarrow': _description_to_arrow_schema,
|
|
199
523
|
}
|
|
200
524
|
|
|
201
525
|
|
|
@@ -204,18 +528,23 @@ def format_results(
|
|
|
204
528
|
desc: List[Description],
|
|
205
529
|
res: Optional[DBAPIResult],
|
|
206
530
|
single: bool = False,
|
|
531
|
+
schema: Optional[Dict[str, Any]] = None,
|
|
207
532
|
) -> Optional[Result]:
|
|
208
533
|
"""
|
|
209
534
|
Convert results to format specified in the package options.
|
|
210
535
|
|
|
211
536
|
Parameters
|
|
212
537
|
----------
|
|
538
|
+
format : str
|
|
539
|
+
Name of the format type
|
|
213
540
|
desc : list of Descriptions
|
|
214
541
|
The column metadata
|
|
215
542
|
res : tuple or list of tuples
|
|
216
543
|
The query results
|
|
217
544
|
single : bool, optional
|
|
218
545
|
Is this a single result (i.e., from `fetchone`)?
|
|
546
|
+
schema : Dict[str, Any], optional
|
|
547
|
+
Cached schema for current output format
|
|
219
548
|
|
|
220
549
|
Returns
|
|
221
550
|
-------
|
|
@@ -225,4 +554,28 @@ def format_results(
|
|
|
225
554
|
If single is True
|
|
226
555
|
|
|
227
556
|
"""
|
|
228
|
-
return _converters[format](desc, res, single)
|
|
557
|
+
return _converters[format](desc, res, single, schema)
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
def get_schema(
|
|
561
|
+
format: str,
|
|
562
|
+
desc: List[Description],
|
|
563
|
+
) -> Dict[str, Any]:
|
|
564
|
+
"""
|
|
565
|
+
Convert a DB-API description to a format schema.
|
|
566
|
+
|
|
567
|
+
Parameters
|
|
568
|
+
----------
|
|
569
|
+
format : str
|
|
570
|
+
Name of the format type
|
|
571
|
+
desc : list of Descriptions
|
|
572
|
+
The column metadata
|
|
573
|
+
|
|
574
|
+
Returns
|
|
575
|
+
-------
|
|
576
|
+
Dict[str, Any]
|
|
577
|
+
A dictionary of function parameters containing schema information
|
|
578
|
+
for the given format type
|
|
579
|
+
|
|
580
|
+
"""
|
|
581
|
+
return _schema_converters[format](desc) or {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: singlestoredb
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Interface to the SingleStoreDB database and workspace management APIs
|
|
5
5
|
Home-page: https://github.com/singlestore-labs/singlestoredb-python
|
|
6
6
|
Author: SingleStore
|
|
@@ -21,6 +21,7 @@ Requires-Dist: requests
|
|
|
21
21
|
Requires-Dist: setuptools
|
|
22
22
|
Requires-Dist: sqlparams
|
|
23
23
|
Requires-Dist: wheel
|
|
24
|
+
Requires-Dist: tomli >=1.1.0 ; python_version < "3.11"
|
|
24
25
|
Provides-Extra: dataframe
|
|
25
26
|
Requires-Dist: ibis-singlestoredb ; extra == 'dataframe'
|
|
26
27
|
Provides-Extra: dbt
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
_singlestoredb_accel.pyd,sha256=
|
|
2
|
-
singlestoredb/__init__.py,sha256=
|
|
1
|
+
_singlestoredb_accel.pyd,sha256=GxBj9VUBHyZgEXboCw4hWGOoZr39LVdqvF_r93oZ5YE,58880
|
|
2
|
+
singlestoredb/__init__.py,sha256=oH6OSgVNPfCC0oK5-yk5Zv7iat7TjxF8WMoV-CSxL2E,1697
|
|
3
3
|
singlestoredb/auth.py,sha256=RmYiH0Wlc2RXc4pTlRMysxtBI445ggCIwojWKC_eDLE,7844
|
|
4
|
-
singlestoredb/config.py,sha256=
|
|
4
|
+
singlestoredb/config.py,sha256=4dWaY_8hdnih6G17BJzJRCCxUisXDljg_3WjMuLDNCI,12032
|
|
5
5
|
singlestoredb/connection.py,sha256=gSKmMN1d_ZSXVTmzfuHK3BXcLyNGiaSi2Vy6z7nymjg,45657
|
|
6
6
|
singlestoredb/converters.py,sha256=stCOsEcZmkfG_Y3jtfIzUmDTt_aMKv4Ir1EDR_r0ceg,13075
|
|
7
7
|
singlestoredb/exceptions.py,sha256=WCCJrNSsU-hD-621Jpd6bwmvGftQ7byXkk-XKXlaxpg,3354
|
|
@@ -10,25 +10,26 @@ singlestoredb/types.py,sha256=Lv0BEQl6aSZBiAe0OSI07FEJhcHZ9HX45iT9NU_mxHQ,10334
|
|
|
10
10
|
singlestoredb/alchemy/__init__.py,sha256=bUmCl1xUn2v36RMbXLIrvgKzZSqx71mp1ReUw9JeVA8,2613
|
|
11
11
|
singlestoredb/functions/__init__.py,sha256=EVxqWOCcXiIX4Yj7rljAYBBoVbTvm2KSuKSkMBDnEeU,42
|
|
12
12
|
singlestoredb/functions/decorator.py,sha256=M103c1JAZfyGFQAU4uJ_J8XGGH3InhcfrNUCoEORNFQ,5335
|
|
13
|
-
singlestoredb/functions/dtypes.py,sha256=
|
|
13
|
+
singlestoredb/functions/dtypes.py,sha256=5IwMSaSzxtSowxXrm5hZXW1lpNm6QILxiU4mAUEkBO0,32854
|
|
14
14
|
singlestoredb/functions/signature.py,sha256=glxf8wVhwpsLOu9s9UEXPaXzBWvl_XN683_dpFyiQ6s,19539
|
|
15
|
-
singlestoredb/functions/ext/__init__.py,sha256=
|
|
15
|
+
singlestoredb/functions/ext/__init__.py,sha256=5ppI8IZN_zOwoJFdu_Oq9ipxtyHw9n6OMVAa_s9T_yY,24
|
|
16
16
|
singlestoredb/functions/ext/arrow.py,sha256=mQhwaMpvCH_dP92WIhP_j-stu272n4UAHsFUOBTgnq0,9436
|
|
17
|
-
singlestoredb/functions/ext/asgi.py,sha256=
|
|
18
|
-
singlestoredb/functions/ext/json.py,sha256=
|
|
19
|
-
singlestoredb/functions/ext/mmap.py,sha256=
|
|
20
|
-
singlestoredb/functions/ext/rowdat_1.py,sha256=
|
|
17
|
+
singlestoredb/functions/ext/asgi.py,sha256=ONC3_8lz8wUAEzC7aG9Z7pmBPxKnZYNLLxas1bdjxcs,41034
|
|
18
|
+
singlestoredb/functions/ext/json.py,sha256=CROdj37cuJhAZ-CM93EI-SoLb4kxFcMGudsJ5QGyCoI,10831
|
|
19
|
+
singlestoredb/functions/ext/mmap.py,sha256=zo6eweOFCZp0KIzAeL1vvuSjqvQhE8ybVhHbU0ZICt4,14124
|
|
20
|
+
singlestoredb/functions/ext/rowdat_1.py,sha256=KYj_y5JWm3_B2-QC47HK-CNOrzujBqGUwLJfE49jwRg,23050
|
|
21
|
+
singlestoredb/functions/ext/utils.py,sha256=OPMFD-tTCx2Kk9jguQkrTr7e4AgNkt15YsvaT1YSmN8,5480
|
|
21
22
|
singlestoredb/fusion/__init__.py,sha256=FHWtrg6OJFTf6Ye197V5sU6ssryr2h6FBcDIgXP7-H4,367
|
|
22
23
|
singlestoredb/fusion/graphql.py,sha256=SHqsPe4xgawdsTPHEtJGQlybYGWqPrGMmyK-v20RLac,5420
|
|
23
|
-
singlestoredb/fusion/handler.py,sha256=
|
|
24
|
-
singlestoredb/fusion/registry.py,sha256=
|
|
24
|
+
singlestoredb/fusion/handler.py,sha256=b8ieJw9xy8BLPeYy_XPexuVvBzMzLX3j28ViLMZUmew,22058
|
|
25
|
+
singlestoredb/fusion/registry.py,sha256=ff52LbgXvMCe7kkrd90Q-3Wib_dWU5rhdD97bSs33CE,5950
|
|
25
26
|
singlestoredb/fusion/result.py,sha256=EcFY5Qv43ySlQsfl_JB-I3ko7PzVdjuhhoKN96uHSAM,12171
|
|
26
27
|
singlestoredb/fusion/handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
singlestoredb/fusion/handlers/stage.py,sha256=
|
|
28
|
+
singlestoredb/fusion/handlers/stage.py,sha256=HPYHKgCCNt2CzY5kLOrn-F6xg7d7-qjJqCZ6i9OOooM,11272
|
|
28
29
|
singlestoredb/fusion/handlers/utils.py,sha256=7xWb_1mJzxW0po9iHVY2ZVnRvHIQgOlKZQZ1zllJBjk,5271
|
|
29
|
-
singlestoredb/fusion/handlers/workspace.py,sha256=
|
|
30
|
+
singlestoredb/fusion/handlers/workspace.py,sha256=6p-h7nCLLluRk2pebom_-pCb4JTjS3XwyflFh7sAEL4,20316
|
|
30
31
|
singlestoredb/http/__init__.py,sha256=4cEDvLloGc3LSpU-PnIwacyu0n5oIIIE6xk2SPyWD_w,939
|
|
31
|
-
singlestoredb/http/connection.py,sha256=
|
|
32
|
+
singlestoredb/http/connection.py,sha256=ASn90MSah73Lh8Wwt21I-OZAjjXCyPTy6Xo7hoaWu30,40048
|
|
32
33
|
singlestoredb/management/__init__.py,sha256=1xAck9ehp2aGsDMAk5paS1Ek1EdjkDlpG1GqMJwm7h0,208
|
|
33
34
|
singlestoredb/management/billing_usage.py,sha256=0UHFSPCrN0nyeGFFM-HXS3NP8pYmYo2BCCahDEPXvzg,3883
|
|
34
35
|
singlestoredb/management/cluster.py,sha256=0GhpuSt_rcFz5f1hzcRHK911KWFewljlV4GFtckB8uM,14822
|
|
@@ -40,9 +41,9 @@ singlestoredb/management/workspace.py,sha256=dZOScGBHGGEs-G8blIGLljtByPqRFVLIH10
|
|
|
40
41
|
singlestoredb/mysql/__init__.py,sha256=CbpwzNUJPAmKPpIobC0-ugBta_RgHCMq7X7N75QLReY,4669
|
|
41
42
|
singlestoredb/mysql/_auth.py,sha256=YaqqyvAHmeraBv3BM207rNveUVPM-mPnW20ts_ynVWg,8341
|
|
42
43
|
singlestoredb/mysql/charset.py,sha256=mnCdMpvdub1S2mm2PSk2j5JddgsWRjsVLtGx-y9TskE,10724
|
|
43
|
-
singlestoredb/mysql/connection.py,sha256=
|
|
44
|
+
singlestoredb/mysql/connection.py,sha256=AZTHsGZwHNqu57yCESPUiDevyDltpy1EcxwRVnBluQA,69263
|
|
44
45
|
singlestoredb/mysql/converters.py,sha256=vebFFm6IrC0WgY-5Eh-esaPizY5cq3vDOUlEKGaYM-U,7771
|
|
45
|
-
singlestoredb/mysql/cursors.py,sha256=
|
|
46
|
+
singlestoredb/mysql/cursors.py,sha256=WQ-vuo2GhjlJFr9d6ISaWV3F1WoW3zrE-WpJQaOwEEc,27366
|
|
46
47
|
singlestoredb/mysql/err.py,sha256=aDbmfq08gWVmfgIea735wSeiFdvYbB5wusgd3qTVq1s,2480
|
|
47
48
|
singlestoredb/mysql/optionfile.py,sha256=bz0cZp8tQZvab1iU7OT0yldHyaMVbvAcUJ3TSNwcmyI,675
|
|
48
49
|
singlestoredb/mysql/protocol.py,sha256=JaAOZjp-Odkma7z7dsQGtd04PxkNB9FxVasN4MTttNI,12568
|
|
@@ -79,15 +80,15 @@ singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py,sh
|
|
|
79
80
|
singlestoredb/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
80
81
|
singlestoredb/tests/empty.sql,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
81
82
|
singlestoredb/tests/local_infile.csv,sha256=0fYxcZcTvcwS2McF4sktFsipRY1G-ClGmCRR1eCqdEQ,45
|
|
82
|
-
singlestoredb/tests/test.sql,sha256=
|
|
83
|
+
singlestoredb/tests/test.sql,sha256=uumkzVL2LHLUEsBhuaPEv2VfL66szBhmtax95u44128,16805
|
|
83
84
|
singlestoredb/tests/test2.sql,sha256=CEM8_lX189iQU65G3Pod7lig6osfrveQyoDz6HC35YQ,38
|
|
84
85
|
singlestoredb/tests/test_basics.py,sha256=MrI0RMisxiLkJEfkuVBhfHd4nPdK-NnqISbeFr4rWlU,45383
|
|
85
86
|
singlestoredb/tests/test_config.py,sha256=Ad0PDmCnJMOyy9f7WTKiRasSR_3mYRByUlSb7k5ZySg,11502
|
|
86
|
-
singlestoredb/tests/test_connection.py,sha256=
|
|
87
|
+
singlestoredb/tests/test_connection.py,sha256=9ZOA8ENI8mOTvYfEVDw4dMsonuvbK3Jra1DeJrMQJ4s,113953
|
|
87
88
|
singlestoredb/tests/test_dbapi.py,sha256=cNJoTEZvYG7ckcwT7xqlkJX-2TDEYGTDDU1Igucp48k,679
|
|
88
89
|
singlestoredb/tests/test_exceptions.py,sha256=vscMYmdOJr0JmkTAJrNI2w0Q96Nfugjkrt5_lYnw8i0,1176
|
|
89
|
-
singlestoredb/tests/test_ext_func.py,sha256=
|
|
90
|
-
singlestoredb/tests/test_ext_func_data.py,sha256=
|
|
90
|
+
singlestoredb/tests/test_ext_func.py,sha256=gQErR-wAN8BqLNG5U4pNbg4qkQEo6Re8Hd9_Ztqo1RM,38550
|
|
91
|
+
singlestoredb/tests/test_ext_func_data.py,sha256=9kn8BWmCjkbnP6hSbFhmhcdW4OmVT-GSvBTIzFBLEys,48796
|
|
91
92
|
singlestoredb/tests/test_fusion.py,sha256=oFfn7vtdMeTEl02JC74JcQHSA6V1BgzAkioBSnruwPs,15565
|
|
92
93
|
singlestoredb/tests/test_http.py,sha256=7hwXe61hlUes3nji0MTTZweo94tJAlJ-vA5ct9geXFQ,8868
|
|
93
94
|
singlestoredb/tests/test_management.py,sha256=WmgsCCpPQTks8WyeD6ZO5ID0B_3GKZphW8I2EeSVAGU,29101
|
|
@@ -102,12 +103,13 @@ singlestoredb/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
|
102
103
|
singlestoredb/utils/config.py,sha256=WVQ567ZzqzlTGueQH5fEpm5tPZuz8y7qvpEQUB-vPjk,25453
|
|
103
104
|
singlestoredb/utils/convert_rows.py,sha256=gkZeZazeJvimCYEQ1FdAC-AmMDwmFGCuP6mi653bpns,1885
|
|
104
105
|
singlestoredb/utils/debug.py,sha256=y7dnJeJGt3U_BWXz9pLt1qNQREpPtumYX_sk1DiqG6Y,362
|
|
106
|
+
singlestoredb/utils/dtypes.py,sha256=_P2fTX2Fgv9Bcl-2L6KivhWgLzyu91sDamxVnmG92Mw,6103
|
|
105
107
|
singlestoredb/utils/mogrify.py,sha256=gCcn99-vgsGVjTUV7RHJ6hH4vCNrsGB_Xo4z8kiSPDQ,4201
|
|
106
|
-
singlestoredb/utils/results.py,sha256=
|
|
108
|
+
singlestoredb/utils/results.py,sha256=sPjqp1x2rClFDMdKny4a0uQcYue2u1mvzLm3siwkDOI,15734
|
|
107
109
|
singlestoredb/utils/xdict.py,sha256=-wi1lSPTnY99fhVMBhPKJ8cCsQhNG4GMUfkEBDKYgCw,13321
|
|
108
|
-
singlestoredb-1.0.
|
|
109
|
-
singlestoredb-1.0.
|
|
110
|
-
singlestoredb-1.0.
|
|
111
|
-
singlestoredb-1.0.
|
|
112
|
-
singlestoredb-1.0.
|
|
113
|
-
singlestoredb-1.0.
|
|
110
|
+
singlestoredb-1.1.0.dist-info/LICENSE,sha256=Bojenzui8aPNjlF3w4ojguDP7sTf8vFV_9Gc2UAG1sg,11542
|
|
111
|
+
singlestoredb-1.1.0.dist-info/METADATA,sha256=XTM4t6QOCmcsrCqVF83QUorvR24W8lF1iws6fwcd1ZA,5710
|
|
112
|
+
singlestoredb-1.1.0.dist-info/WHEEL,sha256=c4k7z5HB0t-y0nBCv6KyJ6KCjn8SEGPddD0lhaPtU3E,96
|
|
113
|
+
singlestoredb-1.1.0.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
|
|
114
|
+
singlestoredb-1.1.0.dist-info/top_level.txt,sha256=SDtemIXf-Kp-_F2f_S6x0db33cHGOILdAEsIQZe2LZc,35
|
|
115
|
+
singlestoredb-1.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|