singlestoredb 1.4.2__tar.gz → 1.5.0__tar.gz

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.

Files changed (128) hide show
  1. {singlestoredb-1.4.2/singlestoredb.egg-info → singlestoredb-1.5.0}/PKG-INFO +1 -1
  2. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/setup.cfg +1 -1
  3. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/__init__.py +1 -1
  4. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/config.py +11 -0
  5. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/connection.py +3 -0
  6. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/fusion/handlers/workspace.py +53 -0
  7. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/http/connection.py +2 -0
  8. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/management/utils.py +20 -4
  9. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/connection.py +19 -0
  10. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/notebook/_portal.py +32 -0
  11. {singlestoredb-1.4.2 → singlestoredb-1.5.0/singlestoredb.egg-info}/PKG-INFO +1 -1
  12. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/LICENSE +0 -0
  13. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/README.md +0 -0
  14. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/accel.c +0 -0
  15. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/setup.py +0 -0
  16. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/ai/__init__.py +0 -0
  17. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/ai/embeddings.py +0 -0
  18. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/alchemy/__init__.py +0 -0
  19. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/auth.py +0 -0
  20. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/converters.py +0 -0
  21. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/exceptions.py +0 -0
  22. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/__init__.py +0 -0
  23. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/decorator.py +0 -0
  24. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/dtypes.py +0 -0
  25. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/ext/__init__.py +0 -0
  26. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/ext/arrow.py +0 -0
  27. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/ext/asgi.py +0 -0
  28. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/ext/json.py +0 -0
  29. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/ext/mmap.py +0 -0
  30. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/ext/rowdat_1.py +0 -0
  31. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/ext/utils.py +0 -0
  32. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/functions/signature.py +0 -0
  33. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/fusion/__init__.py +0 -0
  34. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/fusion/graphql.py +0 -0
  35. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/fusion/handler.py +0 -0
  36. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/fusion/handlers/__init__.py +0 -0
  37. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/fusion/handlers/stage.py +0 -0
  38. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/fusion/handlers/utils.py +0 -0
  39. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/fusion/registry.py +0 -0
  40. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/fusion/result.py +0 -0
  41. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/http/__init__.py +0 -0
  42. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/management/__init__.py +0 -0
  43. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/management/billing_usage.py +0 -0
  44. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/management/cluster.py +0 -0
  45. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/management/manager.py +0 -0
  46. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/management/organization.py +0 -0
  47. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/management/region.py +0 -0
  48. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/management/workspace.py +0 -0
  49. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/__init__.py +0 -0
  50. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/_auth.py +0 -0
  51. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/charset.py +0 -0
  52. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/CLIENT.py +0 -0
  53. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/COMMAND.py +0 -0
  54. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/CR.py +0 -0
  55. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/ER.py +0 -0
  56. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/EXTENDED_TYPE.py +0 -0
  57. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/FIELD_TYPE.py +0 -0
  58. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/FLAG.py +0 -0
  59. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/SERVER_STATUS.py +0 -0
  60. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/VECTOR_TYPE.py +0 -0
  61. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/constants/__init__.py +0 -0
  62. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/converters.py +0 -0
  63. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/cursors.py +0 -0
  64. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/err.py +0 -0
  65. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/optionfile.py +0 -0
  66. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/protocol.py +0 -0
  67. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/__init__.py +0 -0
  68. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/base.py +0 -0
  69. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/conftest.py +0 -0
  70. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_DictCursor.py +0 -0
  71. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_SSCursor.py +0 -0
  72. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_basic.py +0 -0
  73. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_connection.py +0 -0
  74. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_converters.py +0 -0
  75. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_cursor.py +0 -0
  76. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_err.py +0 -0
  77. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_issues.py +0 -0
  78. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_load_local.py +0 -0
  79. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_nextset.py +0 -0
  80. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/test_optionfile.py +0 -0
  81. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/thirdparty/__init__.py +0 -0
  82. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/__init__.py +0 -0
  83. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/capabilities.py +0 -0
  84. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/dbapi20.py +0 -0
  85. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_capabilities.py +0 -0
  86. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py +0 -0
  87. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py +0 -0
  88. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/mysql/times.py +0 -0
  89. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/notebook/__init__.py +0 -0
  90. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/notebook/_objects.py +0 -0
  91. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/pytest.py +0 -0
  92. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/__init__.py +0 -0
  93. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/empty.sql +0 -0
  94. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/ext_funcs/__init__.py +0 -0
  95. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/local_infile.csv +0 -0
  96. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test.sql +0 -0
  97. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test2.sql +0 -0
  98. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_basics.py +0 -0
  99. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_config.py +0 -0
  100. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_connection.py +0 -0
  101. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_dbapi.py +0 -0
  102. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_exceptions.py +0 -0
  103. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_ext_func.py +0 -0
  104. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_ext_func_data.py +0 -0
  105. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_fusion.py +0 -0
  106. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_http.py +0 -0
  107. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_management.py +0 -0
  108. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_plugin.py +0 -0
  109. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_results.py +0 -0
  110. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_types.py +0 -0
  111. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_udf.py +0 -0
  112. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/test_xdict.py +0 -0
  113. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/tests/utils.py +0 -0
  114. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/types.py +0 -0
  115. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/utils/__init__.py +0 -0
  116. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/utils/config.py +0 -0
  117. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/utils/convert_rows.py +0 -0
  118. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/utils/debug.py +0 -0
  119. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/utils/dtypes.py +0 -0
  120. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/utils/events.py +0 -0
  121. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/utils/mogrify.py +0 -0
  122. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/utils/results.py +0 -0
  123. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb/utils/xdict.py +0 -0
  124. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb.egg-info/SOURCES.txt +0 -0
  125. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb.egg-info/dependency_links.txt +0 -0
  126. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb.egg-info/entry_points.txt +0 -0
  127. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb.egg-info/requires.txt +0 -0
  128. {singlestoredb-1.4.2 → singlestoredb-1.5.0}/singlestoredb.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: singlestoredb
3
- Version: 1.4.2
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,6 +1,6 @@
1
1
  [metadata]
2
2
  name = singlestoredb
3
- version = 1.4.2
3
+ version = 1.5.0
4
4
  description = Interface to the SingleStoreDB database and workspace management APIs
5
5
  long_description = file: README.md
6
6
  long_description_content_type = text/markdown
@@ -13,7 +13,7 @@ Examples
13
13
 
14
14
  """
15
15
 
16
- __version__ = '1.4.2'
16
+ __version__ = '1.5.0'
17
17
 
18
18
  from typing import Any
19
19
 
@@ -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()))
@@ -123,14 +123,14 @@ class NamedList(List[T]):
123
123
  def _setup_authentication_info_handler() -> Callable[..., Dict[str, Any]]:
124
124
  """Setup authentication info event handler."""
125
125
 
126
- authentication_info: List[Tuple[str, Any]] = []
126
+ authentication_info: Dict[str, Any] = {}
127
127
 
128
128
  def handle_authentication_info(msg: Dict[str, Any]) -> None:
129
129
  """Handle authentication info events."""
130
130
  nonlocal authentication_info
131
131
  if msg.get('name', '') != 'singlestore.portal.authentication_updated':
132
132
  return
133
- authentication_info = list(msg.get('data', {}).items())
133
+ authentication_info = dict(msg.get('data', {}))
134
134
 
135
135
  events.subscribe(handle_authentication_info)
136
136
 
@@ -145,11 +145,27 @@ def _setup_authentication_info_handler() -> Callable[..., Dict[str, Any]]:
145
145
  out['user'] = data['user']
146
146
  if 'password' in data:
147
147
  out['password'] = data['password']
148
- authentication_info = list(out.items())
148
+ authentication_info = out
149
149
 
150
150
  events.subscribe(handle_authentication_info)
151
151
 
152
+ def retrieve_current_authentication_info() -> List[Tuple[str, Any]]:
153
+ """Retrieve JWT if not expired."""
154
+ nonlocal authentication_info
155
+ password = authentication_info.get('password')
156
+ if password:
157
+ expires = datetime.datetime.fromtimestamp(
158
+ jwt.decode(
159
+ password,
160
+ options={'verify_signature': False},
161
+ )['exp'],
162
+ )
163
+ if datetime.datetime.now() > expires:
164
+ authentication_info = {}
165
+ return list(authentication_info.items())
166
+
152
167
  def get_env() -> List[Tuple[str, Any]]:
168
+ """Retrieve JWT from environment."""
153
169
  conn = {}
154
170
  url = os.environ.get('SINGLESTOREDB_URL') or get_option('host')
155
171
  if url:
@@ -170,7 +186,7 @@ def _setup_authentication_info_handler() -> Callable[..., Dict[str, Any]]:
170
186
  return dict(
171
187
  itertools.chain(
172
188
  (get_env() if include_env else []),
173
- authentication_info,
189
+ retrieve_current_authentication_info(),
174
190
  ),
175
191
  )
176
192
 
@@ -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.2
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
File without changes
File without changes
File without changes
File without changes