singlestoredb 1.4.3__py3-none-any.whl → 1.5.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.
Potentially problematic release.
This version of singlestoredb might be problematic. Click here for more details.
- singlestoredb/__init__.py +1 -1
- singlestoredb/config.py +11 -0
- singlestoredb/connection.py +3 -0
- singlestoredb/fusion/handlers/workspace.py +53 -0
- singlestoredb/http/connection.py +2 -0
- singlestoredb/mysql/connection.py +19 -0
- singlestoredb/notebook/_portal.py +32 -0
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.5.0.dist-info}/METADATA +1 -1
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.5.0.dist-info}/RECORD +13 -13
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.5.0.dist-info}/LICENSE +0 -0
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.5.0.dist-info}/WHEEL +0 -0
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.5.0.dist-info}/entry_points.txt +0 -0
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.5.0.dist-info}/top_level.txt +0 -0
singlestoredb/__init__.py
CHANGED
singlestoredb/config.py
CHANGED
|
@@ -221,6 +221,17 @@ register_option(
|
|
|
221
221
|
environ='SINGLESTOREDB_ENABLE_EXTENDED_DATA_TYPES',
|
|
222
222
|
)
|
|
223
223
|
|
|
224
|
+
register_option(
|
|
225
|
+
'vector_data_format', 'string',
|
|
226
|
+
functools.partial(
|
|
227
|
+
check_str,
|
|
228
|
+
valid_values=['json', 'binary'],
|
|
229
|
+
),
|
|
230
|
+
'binary',
|
|
231
|
+
'Format for vector data values',
|
|
232
|
+
environ='SINGLESTOREDB_VECTOR_DATA_FORMAT',
|
|
233
|
+
)
|
|
234
|
+
|
|
224
235
|
register_option(
|
|
225
236
|
'fusion.enabled', 'bool', check_bool, False,
|
|
226
237
|
'Should Fusion SQL queries be enabled?',
|
singlestoredb/connection.py
CHANGED
|
@@ -1304,6 +1304,7 @@ def connect(
|
|
|
1304
1304
|
encoding_errors: Optional[str] = None,
|
|
1305
1305
|
track_env: Optional[bool] = None,
|
|
1306
1306
|
enable_extended_data_types: Optional[bool] = None,
|
|
1307
|
+
vector_data_format: Optional[str] = None,
|
|
1307
1308
|
) -> Connection:
|
|
1308
1309
|
"""
|
|
1309
1310
|
Return a SingleStoreDB connection.
|
|
@@ -1387,6 +1388,8 @@ def connect(
|
|
|
1387
1388
|
Should the connection track the SINGLESTOREDB_URL environment variable?
|
|
1388
1389
|
enable_extended_data_types : bool, optional
|
|
1389
1390
|
Should extended data types (BSON, vector) be enabled?
|
|
1391
|
+
vector_data_format : str, optional
|
|
1392
|
+
Format for vector types: json or binary
|
|
1390
1393
|
|
|
1391
1394
|
Examples
|
|
1392
1395
|
--------
|
|
@@ -13,6 +13,59 @@ from .utils import get_workspace_group
|
|
|
13
13
|
from .utils import get_workspace_manager
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
class UseWorkspaceHandler(SQLHandler):
|
|
17
|
+
"""
|
|
18
|
+
USE WORKSPACE workspace [ with_database ];
|
|
19
|
+
|
|
20
|
+
# Workspace
|
|
21
|
+
workspace = { workspace_id | workspace_name }
|
|
22
|
+
|
|
23
|
+
# ID of workspace
|
|
24
|
+
workspace_id = ID '<workspace-id>'
|
|
25
|
+
|
|
26
|
+
# Name of workspace
|
|
27
|
+
workspace_name = '<workspace-name>'
|
|
28
|
+
|
|
29
|
+
# Name of database
|
|
30
|
+
with_database = WITH DATABASE 'database-name'
|
|
31
|
+
|
|
32
|
+
Description
|
|
33
|
+
-----------
|
|
34
|
+
Change the workspace and database in the notebook.
|
|
35
|
+
|
|
36
|
+
Arguments
|
|
37
|
+
---------
|
|
38
|
+
* ``<workspace-id>``: The ID of the workspace to delete.
|
|
39
|
+
* ``<workspace-name>``: The name of the workspace to delete.
|
|
40
|
+
|
|
41
|
+
Remarks
|
|
42
|
+
-------
|
|
43
|
+
* Specify the ``WITH DATABASE`` clause to select a default
|
|
44
|
+
database for the session.
|
|
45
|
+
* This command only works in a notebook session in the
|
|
46
|
+
Managed Service.
|
|
47
|
+
|
|
48
|
+
Example
|
|
49
|
+
-------
|
|
50
|
+
The following command sets the workspace to ``examplews`` and
|
|
51
|
+
select 'dbname' as the default database::
|
|
52
|
+
|
|
53
|
+
USE WORKSPACE 'examplews' WITH DATABASE 'dbname';
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
|
|
57
|
+
from singlestoredb.notebook import portal
|
|
58
|
+
if params.get('with_database'):
|
|
59
|
+
portal.connection = params['workspace']['workspace_name'], \
|
|
60
|
+
params['with_database']
|
|
61
|
+
else:
|
|
62
|
+
portal.workspace = params['workspace']['workspace_name']
|
|
63
|
+
return None
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
UseWorkspaceHandler.register(overwrite=True)
|
|
67
|
+
|
|
68
|
+
|
|
16
69
|
class ShowRegionsHandler(SQLHandler):
|
|
17
70
|
"""
|
|
18
71
|
SHOW REGIONS [ <like> ]
|
singlestoredb/http/connection.py
CHANGED
|
@@ -1243,5 +1243,7 @@ def connect(
|
|
|
1243
1243
|
inf_as_null: Optional[bool] = None,
|
|
1244
1244
|
encoding_errors: Optional[str] = None,
|
|
1245
1245
|
track_env: Optional[bool] = None,
|
|
1246
|
+
enable_extended_data_types: Optional[bool] = None,
|
|
1247
|
+
vector_data_format: Optional[str] = None,
|
|
1246
1248
|
) -> Connection:
|
|
1247
1249
|
return Connection(**dict(locals()))
|
|
@@ -280,6 +280,8 @@ class Connection(BaseConnection):
|
|
|
280
280
|
Should the connection track the SINGLESTOREDB_URL environment variable?
|
|
281
281
|
enable_extended_data_types : bool, optional
|
|
282
282
|
Should extended data types (BSON, vector) be enabled?
|
|
283
|
+
vector_data_format : str, optional
|
|
284
|
+
Specify the data type of vector values: json or binary
|
|
283
285
|
|
|
284
286
|
See `Connection <https://www.python.org/dev/peps/pep-0249/#connection-objects>`_
|
|
285
287
|
in the specification.
|
|
@@ -350,6 +352,7 @@ class Connection(BaseConnection):
|
|
|
350
352
|
encoding_errors='strict',
|
|
351
353
|
track_env=False,
|
|
352
354
|
enable_extended_data_types=True,
|
|
355
|
+
vector_data_format='binary',
|
|
353
356
|
):
|
|
354
357
|
BaseConnection.__init__(**dict(locals()))
|
|
355
358
|
|
|
@@ -634,6 +637,13 @@ class Connection(BaseConnection):
|
|
|
634
637
|
self._in_sync = False
|
|
635
638
|
self._track_env = bool(track_env) or self.host == 'singlestore.com'
|
|
636
639
|
self._enable_extended_data_types = enable_extended_data_types
|
|
640
|
+
if vector_data_format.lower() in ['json', 'binary']:
|
|
641
|
+
self._vector_data_format = vector_data_format
|
|
642
|
+
else:
|
|
643
|
+
raise ValueError(
|
|
644
|
+
'unknown value for vector_data_format, '
|
|
645
|
+
f'expecting "json" or "binary": {vector_data_format}',
|
|
646
|
+
)
|
|
637
647
|
self._connection_info = {}
|
|
638
648
|
events.subscribe(self._handle_event)
|
|
639
649
|
|
|
@@ -1117,6 +1127,15 @@ class Connection(BaseConnection):
|
|
|
1117
1127
|
pass
|
|
1118
1128
|
c.close()
|
|
1119
1129
|
|
|
1130
|
+
if self._vector_data_format:
|
|
1131
|
+
c = self.cursor()
|
|
1132
|
+
try:
|
|
1133
|
+
val = self._vector_data_format
|
|
1134
|
+
c.execute(f'SET @@SESSION.vector_type_project_format={val}')
|
|
1135
|
+
except self.OperationalError:
|
|
1136
|
+
pass
|
|
1137
|
+
c.close()
|
|
1138
|
+
|
|
1120
1139
|
if self.init_command is not None:
|
|
1121
1140
|
c = self.cursor()
|
|
1122
1141
|
c.execute(self.init_command)
|
|
@@ -9,6 +9,7 @@ from typing import Callable
|
|
|
9
9
|
from typing import Dict
|
|
10
10
|
from typing import List
|
|
11
11
|
from typing import Optional
|
|
12
|
+
from typing import Tuple
|
|
12
13
|
|
|
13
14
|
from . import _objects as obj
|
|
14
15
|
from ..management import workspace as mgr
|
|
@@ -187,6 +188,37 @@ class Portal(object):
|
|
|
187
188
|
timeout_message='timeout waiting for workspace update',
|
|
188
189
|
)
|
|
189
190
|
|
|
191
|
+
deployment = workspace
|
|
192
|
+
|
|
193
|
+
@property
|
|
194
|
+
def connection(self) -> Tuple[obj.Workspace, Optional[str]]:
|
|
195
|
+
"""Workspace and default database name."""
|
|
196
|
+
return self.workspace, self.default_database
|
|
197
|
+
|
|
198
|
+
@connection.setter
|
|
199
|
+
def connection(self, workspace_and_default_database: Tuple[str, str]) -> None:
|
|
200
|
+
"""Set workspace and default database name."""
|
|
201
|
+
name_or_id, default_database = workspace_and_default_database
|
|
202
|
+
if re.match(
|
|
203
|
+
r'[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}',
|
|
204
|
+
name_or_id, flags=re.I,
|
|
205
|
+
):
|
|
206
|
+
w = mgr.get_workspace(name_or_id)
|
|
207
|
+
else:
|
|
208
|
+
w = mgr.get_workspace_group(self.workspace_group_id).workspaces[name_or_id]
|
|
209
|
+
|
|
210
|
+
if w.state and w.state.lower() not in ['active', 'resumed']:
|
|
211
|
+
raise RuntimeError('workspace is not active')
|
|
212
|
+
|
|
213
|
+
id = w.id
|
|
214
|
+
|
|
215
|
+
self._call_javascript(
|
|
216
|
+
'changeConnection', [id, default_database],
|
|
217
|
+
wait_on_condition=lambda: self.workspace_id == id and
|
|
218
|
+
self.default_database == default_database, # type: ignore
|
|
219
|
+
timeout_message='timeout waiting for workspace update',
|
|
220
|
+
)
|
|
221
|
+
|
|
190
222
|
@property
|
|
191
223
|
def cluster_id(self) -> Optional[str]:
|
|
192
224
|
"""Cluster ID."""
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
singlestoredb/__init__.py,sha256=
|
|
1
|
+
singlestoredb/__init__.py,sha256=uEuDac8tSZiJCE2NiWh3zAtGwMalgs9DTd-xAsWHGYM,1634
|
|
2
2
|
singlestoredb/auth.py,sha256=u8D9tpKzrqa4ssaHjyZnGDX1q8XBpGtuoOkTkSv7B28,7599
|
|
3
|
-
singlestoredb/config.py,sha256=
|
|
4
|
-
singlestoredb/connection.py,sha256=
|
|
3
|
+
singlestoredb/config.py,sha256=0qU2lweqHIA5yuV0ZN_JS-cZCfLIxIHutgS2YKRuwXw,12067
|
|
4
|
+
singlestoredb/connection.py,sha256=Gzq38vG8lXTx5v2WvHkdMg-abSTS6lguTsVMxbYHZmQ,45306
|
|
5
5
|
singlestoredb/converters.py,sha256=t1hRMZfccWJs_WyOw-W-Kh87fxsOkpOnKXAeh_Nr-zU,20681
|
|
6
6
|
singlestoredb/exceptions.py,sha256=HuoA6sMRL5qiCiee-_5ddTGmFbYC9Euk8TYUsh5GvTw,3234
|
|
7
7
|
singlestoredb/pytest.py,sha256=OyF3BO9mgxenifYhOihnzGk8WzCJ_zN5_mxe8XyFPOc,9074
|
|
@@ -28,9 +28,9 @@ singlestoredb/fusion/result.py,sha256=Bd3KbRpqWqQcWp_Chd4bzBy8Kfc8nXLS_Pn_GGbPO6
|
|
|
28
28
|
singlestoredb/fusion/handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
29
|
singlestoredb/fusion/handlers/stage.py,sha256=4BSwqcmA4PI3oksTdYaTmQ6bY-AzmL0mZfGnP3U0ldM,13643
|
|
30
30
|
singlestoredb/fusion/handlers/utils.py,sha256=oYbf13Y3orEkJfHMNnO7B_W1anEdK-0S9vVVkF2pPFk,5109
|
|
31
|
-
singlestoredb/fusion/handlers/workspace.py,sha256=
|
|
31
|
+
singlestoredb/fusion/handlers/workspace.py,sha256=faVuqiE4PTVOAgbsr18MOc7H92nVzfwga0SUTPODvSc,26455
|
|
32
32
|
singlestoredb/http/__init__.py,sha256=A_2ZUCCpvRYIA6YDpPy57wL5R1eZ5SfP6I1To5nfJ2s,912
|
|
33
|
-
singlestoredb/http/connection.py,sha256=
|
|
33
|
+
singlestoredb/http/connection.py,sha256=T2NrL7XV30eQRdrcbP_IY8c3ZOV6Th4KQiuleW4tHUE,39450
|
|
34
34
|
singlestoredb/management/__init__.py,sha256=mhWXjLhp5-t8dhl0vl7SjayKrvJlDb5_hl1YWvDgiMA,237
|
|
35
35
|
singlestoredb/management/billing_usage.py,sha256=9ighjIpcopgIyJOktBYQ6pahBZmWGHOPyyCW4gu9FGs,3735
|
|
36
36
|
singlestoredb/management/cluster.py,sha256=i23Smr1PBrDZ8NO_VPd_-bEYkyHvVe9CCRGUjHn_1yQ,14362
|
|
@@ -42,7 +42,7 @@ singlestoredb/management/workspace.py,sha256=9oamNIaE5vLZNAlpl5SK-xu27qPqx2Ff3ZI
|
|
|
42
42
|
singlestoredb/mysql/__init__.py,sha256=olUTAvkiERhDW41JXQMawkg-i0tvBEkoTkII1tt6lxU,4492
|
|
43
43
|
singlestoredb/mysql/_auth.py,sha256=AugRitoUwgRIDFuJxuAH4MWIAmckY7Ji2pP6r_Ng9dY,8043
|
|
44
44
|
singlestoredb/mysql/charset.py,sha256=-FlONDS_oAUF5B3mIgeHBPb_SCt4zHD33arUeBNctU0,10510
|
|
45
|
-
singlestoredb/mysql/connection.py,sha256=
|
|
45
|
+
singlestoredb/mysql/connection.py,sha256=cUVILM5q2tVkGAf-GpPK2pvPto3AOB_9PifK8iXaiKw,72216
|
|
46
46
|
singlestoredb/mysql/converters.py,sha256=CVe8SDmjbIAhy1xpQ2N5OKWw6t5eWpw-EU3QTlA0Hh0,7500
|
|
47
47
|
singlestoredb/mysql/cursors.py,sha256=Eqe7jITRvOo4P_TxIarTumg_2PG1DcCfZ4Uo9IFdDa8,26794
|
|
48
48
|
singlestoredb/mysql/err.py,sha256=-m5rqXi8yhq6b8SCEJ2h0E5Rudh_15dlAU_WbJ1YrM8,2388
|
|
@@ -82,7 +82,7 @@ singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py,sha256
|
|
|
82
82
|
singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py,sha256=pl0bvuZo_nzAlYOINxRiR-Zi9khz0W2Pc7vP-K3sQYQ,2819
|
|
83
83
|
singlestoredb/notebook/__init__.py,sha256=v0j1E3MFAtaC8wTrR-F7XY0nytUvQ4XpYhVXddv2xA0,533
|
|
84
84
|
singlestoredb/notebook/_objects.py,sha256=MkB1eowEq5SQXFHY00xAKAyyeLqHu_uaZiA20BCJPaE,8043
|
|
85
|
-
singlestoredb/notebook/_portal.py,sha256=
|
|
85
|
+
singlestoredb/notebook/_portal.py,sha256=DLerIEQmAUymtYcx8RBeuYJ4pJSy_xl1K6t1Oc-eTf8,9698
|
|
86
86
|
singlestoredb/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
87
87
|
singlestoredb/tests/empty.sql,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
88
88
|
singlestoredb/tests/local_infile.csv,sha256=sBtqjvfkS9aoOVx8nMXYgYv4rDuT4OuYhqUhNRu0O68,42
|
|
@@ -114,9 +114,9 @@ singlestoredb/utils/events.py,sha256=9IB84T3pKQjs7aaoSSJCw7soNngnhoTDWIC52M51R9Y
|
|
|
114
114
|
singlestoredb/utils/mogrify.py,sha256=-a56IF70U6CkfadeaZgfjRSVsAD3PuqRrzPpjZlgbwY,4050
|
|
115
115
|
singlestoredb/utils/results.py,sha256=bJtaUaDiFq26IsPAKZ2FHGB7csMn94EAxLKrP4HaEEA,15277
|
|
116
116
|
singlestoredb/utils/xdict.py,sha256=S9HKgrPrnu_6b7iOwa2KrW8CmU1Uqx0BWdEyogFzWbE,12896
|
|
117
|
-
singlestoredb-1.
|
|
118
|
-
singlestoredb-1.
|
|
119
|
-
singlestoredb-1.
|
|
120
|
-
singlestoredb-1.
|
|
121
|
-
singlestoredb-1.
|
|
122
|
-
singlestoredb-1.
|
|
117
|
+
singlestoredb-1.5.0.dist-info/LICENSE,sha256=Mlq78idURT-9G026aMYswwwnnrLcgzTLuXeAs5hjDLM,11341
|
|
118
|
+
singlestoredb-1.5.0.dist-info/METADATA,sha256=NNlSvXOAcd1pZGUOnuUM46RAZdw6LInc8KtKhDODwJw,5570
|
|
119
|
+
singlestoredb-1.5.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
120
|
+
singlestoredb-1.5.0.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
|
|
121
|
+
singlestoredb-1.5.0.dist-info/top_level.txt,sha256=eet8bVPNRqiGeY0PrO5ERH2UpamwlrKHEQCffz4dOh8,14
|
|
122
|
+
singlestoredb-1.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|