singlestoredb 1.4.3__cp38-abi3-win32.whl → 1.5.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 CHANGED
Binary file
singlestoredb/__init__.py CHANGED
@@ -13,7 +13,7 @@ Examples
13
13
 
14
14
  """
15
15
 
16
- __version__ = '1.4.3'
16
+ __version__ = '1.5.0'
17
17
 
18
18
  from typing import Any
19
19
 
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?',
@@ -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> ]
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: singlestoredb
3
- Version: 1.4.3
3
+ Version: 1.5.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
@@ -1,8 +1,8 @@
1
- _singlestoredb_accel.pyd,sha256=JySQW9UIgy08VK7a0_0SsWZ6didExBbAyUUs4QIWxok,59904
2
- singlestoredb/__init__.py,sha256=coTKAx_9TGFvUHphEf4cQk0Sd6wuK9ZrZuGjJmDVxw0,1697
1
+ _singlestoredb_accel.pyd,sha256=Fe88gHmUq8Dh80VyPCuEbhDxA3ygjCZ8wriiT-AMSY8,59904
2
+ singlestoredb/__init__.py,sha256=JmRMLxVTnSEebFN9UCjgzhvHrFwwih57UKmtuWjPCTo,1697
3
3
  singlestoredb/auth.py,sha256=RmYiH0Wlc2RXc4pTlRMysxtBI445ggCIwojWKC_eDLE,7844
4
- singlestoredb/config.py,sha256=9pVmVEZ23NfJ3pokdBDA0cX3bwUz6SbuT4AZWAcIPR4,12235
5
- singlestoredb/connection.py,sha256=xdjf6HX-BS9BmwdjA3IlKeZx_e691_dVFMY3GvX_v64,46629
4
+ singlestoredb/config.py,sha256=U2v66Ua0eLWWOcmD9-XfCG-bjqQCHS6iMSejiogXVbw,12491
5
+ singlestoredb/connection.py,sha256=CvdVyLfR_08ONma1BiwqqjVVSsdXxeHdfpR-zaq0wwc,46765
6
6
  singlestoredb/converters.py,sha256=7_Of1f3Ow-JUoY1pHFlMPYxvt8llzdk-7X8qk5z2xJM,21631
7
7
  singlestoredb/exceptions.py,sha256=WCCJrNSsU-hD-621Jpd6bwmvGftQ7byXkk-XKXlaxpg,3354
8
8
  singlestoredb/pytest.py,sha256=TH364xRCN7_QaN0oRQDHixrEcDx_ZBgu3bmY0tvKrYU,9357
@@ -29,9 +29,9 @@ singlestoredb/fusion/result.py,sha256=EcFY5Qv43ySlQsfl_JB-I3ko7PzVdjuhhoKN96uHSA
29
29
  singlestoredb/fusion/handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  singlestoredb/fusion/handlers/stage.py,sha256=uPqawMvchnpyrPYLhB0joTremCURNYKOvYntFc3zTRU,14133
31
31
  singlestoredb/fusion/handlers/utils.py,sha256=7xWb_1mJzxW0po9iHVY2ZVnRvHIQgOlKZQZ1zllJBjk,5271
32
- singlestoredb/fusion/handlers/workspace.py,sha256=lzTaa55QfKuwuSCGbrlk4B_hPQ6xcjZ8oZFDz-Vznxo,25815
32
+ singlestoredb/fusion/handlers/workspace.py,sha256=i2DllEVcBEzSKVPp380ezqFT5gcbluhk-OjEo17ejnQ,27323
33
33
  singlestoredb/http/__init__.py,sha256=4cEDvLloGc3LSpU-PnIwacyu0n5oIIIE6xk2SPyWD_w,939
34
- singlestoredb/http/connection.py,sha256=zIkVfemoXPPlCDEvms698icd5nf8X_pK1YorDVgLDvs,40596
34
+ singlestoredb/http/connection.py,sha256=dbMIxT5CeD5ABnXgFwY9fFbW42IXQWUi3ZC6ID7mnPY,40699
35
35
  singlestoredb/management/__init__.py,sha256=pQbsOffl-i6zIzR63MCxSjxPY6TNmy7Kg0BCTExt3mk,244
36
36
  singlestoredb/management/billing_usage.py,sha256=0UHFSPCrN0nyeGFFM-HXS3NP8pYmYo2BCCahDEPXvzg,3883
37
37
  singlestoredb/management/cluster.py,sha256=XfdBuTlrAG-mnW1BFKeoAr4YSE5IVgxLjbuBSpqIySo,14823
@@ -43,7 +43,7 @@ singlestoredb/management/workspace.py,sha256=BBNa3Af5IaUAwtzHWrNTJXoc8anXJ7FiWH9
43
43
  singlestoredb/mysql/__init__.py,sha256=CbpwzNUJPAmKPpIobC0-ugBta_RgHCMq7X7N75QLReY,4669
44
44
  singlestoredb/mysql/_auth.py,sha256=YaqqyvAHmeraBv3BM207rNveUVPM-mPnW20ts_ynVWg,8341
45
45
  singlestoredb/mysql/charset.py,sha256=mnCdMpvdub1S2mm2PSk2j5JddgsWRjsVLtGx-y9TskE,10724
46
- singlestoredb/mysql/connection.py,sha256=ev6CZ7iFK7oBeC2bBNsAK9hYr2OXpBiVeALch-DekHo,73435
46
+ singlestoredb/mysql/connection.py,sha256=d8gtajX4SWbBk6dpOKqQX_ZS5_wNiCmrvZ1gVV294io,74224
47
47
  singlestoredb/mysql/converters.py,sha256=vebFFm6IrC0WgY-5Eh-esaPizY5cq3vDOUlEKGaYM-U,7771
48
48
  singlestoredb/mysql/cursors.py,sha256=pkrP-1t8IhBJRnYpdM7Rdm-332nOq1RYTDJ_yg_q5HI,27682
49
49
  singlestoredb/mysql/err.py,sha256=aDbmfq08gWVmfgIea735wSeiFdvYbB5wusgd3qTVq1s,2480
@@ -83,7 +83,7 @@ singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py,sha256
83
83
  singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py,sha256=K4EnQCWI_4ShmCv6xHSBDo0B2HVbJvGGYHWygp2bBBk,2920
84
84
  singlestoredb/notebook/__init__.py,sha256=XGvAnkjV_6MjaNv6aqxqDL3ovPApKmNX-2UYH1t0cec,549
85
85
  singlestoredb/notebook/_objects.py,sha256=rDfHGLLwrnuhVMOyNojzrGamykyfOQxZfH2EnFd8vEw,8256
86
- singlestoredb/notebook/_portal.py,sha256=uMjc1LnwpSfkuQehyOxUu3WBAUdKU9EaYAJBdTDw_8E,8767
86
+ singlestoredb/notebook/_portal.py,sha256=ip3MkJ51syxppUVGRjgqLfR0He4KCZVklFwWT_X270s,10011
87
87
  singlestoredb/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
88
88
  singlestoredb/tests/empty.sql,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
89
89
  singlestoredb/tests/local_infile.csv,sha256=0fYxcZcTvcwS2McF4sktFsipRY1G-ClGmCRR1eCqdEQ,45
@@ -115,9 +115,9 @@ singlestoredb/utils/events.py,sha256=rC9cHAetua_E1f-EiFkFM-gJzQSQIH5Uk-4sspC3KjI
115
115
  singlestoredb/utils/mogrify.py,sha256=gCcn99-vgsGVjTUV7RHJ6hH4vCNrsGB_Xo4z8kiSPDQ,4201
116
116
  singlestoredb/utils/results.py,sha256=wR70LhCqlobniZf52r67zYLBOKjWHQm68NAskdRQND8,15862
117
117
  singlestoredb/utils/xdict.py,sha256=-wi1lSPTnY99fhVMBhPKJ8cCsQhNG4GMUfkEBDKYgCw,13321
118
- singlestoredb-1.4.3.dist-info/LICENSE,sha256=Bojenzui8aPNjlF3w4ojguDP7sTf8vFV_9Gc2UAG1sg,11542
119
- singlestoredb-1.4.3.dist-info/METADATA,sha256=JN_3ss7jeom5-_yVxjoSS-zCxNGwFTiqHEE5X991QZk,5710
120
- singlestoredb-1.4.3.dist-info/WHEEL,sha256=c4k7z5HB0t-y0nBCv6KyJ6KCjn8SEGPddD0lhaPtU3E,96
121
- singlestoredb-1.4.3.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
122
- singlestoredb-1.4.3.dist-info/top_level.txt,sha256=SDtemIXf-Kp-_F2f_S6x0db33cHGOILdAEsIQZe2LZc,35
123
- singlestoredb-1.4.3.dist-info/RECORD,,
118
+ singlestoredb-1.5.0.dist-info/LICENSE,sha256=Bojenzui8aPNjlF3w4ojguDP7sTf8vFV_9Gc2UAG1sg,11542
119
+ singlestoredb-1.5.0.dist-info/METADATA,sha256=bENk-7v217z-lq59jAreazeMlGOaNo59QyWDIammDvo,5710
120
+ singlestoredb-1.5.0.dist-info/WHEEL,sha256=c4k7z5HB0t-y0nBCv6KyJ6KCjn8SEGPddD0lhaPtU3E,96
121
+ singlestoredb-1.5.0.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
122
+ singlestoredb-1.5.0.dist-info/top_level.txt,sha256=SDtemIXf-Kp-_F2f_S6x0db33cHGOILdAEsIQZe2LZc,35
123
+ singlestoredb-1.5.0.dist-info/RECORD,,