singlestoredb 1.4.3__py3-none-any.whl → 1.6.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/handler.py +17 -9
- singlestoredb/fusion/handlers/job.py +658 -0
- singlestoredb/fusion/handlers/workspace.py +81 -5
- singlestoredb/http/connection.py +2 -0
- singlestoredb/management/job.py +887 -0
- singlestoredb/management/organization.py +17 -0
- singlestoredb/management/utils.py +47 -1
- singlestoredb/mysql/connection.py +19 -0
- singlestoredb/notebook/_portal.py +32 -0
- singlestoredb/tests/test_fusion.py +250 -1
- singlestoredb/tests/test_management.py +152 -0
- singlestoredb/tests/utils.py +7 -0
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.6.0.dist-info}/METADATA +1 -1
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.6.0.dist-info}/RECORD +21 -19
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.6.0.dist-info}/LICENSE +0 -0
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.6.0.dist-info}/WHEEL +0 -0
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.6.0.dist-info}/entry_points.txt +0 -0
- {singlestoredb-1.4.3.dist-info → singlestoredb-1.6.0.dist-info}/top_level.txt +0 -0
|
@@ -13,6 +13,73 @@ 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 | current_workspace }
|
|
22
|
+
|
|
23
|
+
# ID of workspace
|
|
24
|
+
workspace_id = ID '<workspace-id>'
|
|
25
|
+
|
|
26
|
+
# Name of workspace
|
|
27
|
+
workspace_name = '<workspace-name>'
|
|
28
|
+
|
|
29
|
+
# Current workspace
|
|
30
|
+
current_workspace = @@CURRENT
|
|
31
|
+
|
|
32
|
+
# Name of database
|
|
33
|
+
with_database = WITH DATABASE 'database-name'
|
|
34
|
+
|
|
35
|
+
Description
|
|
36
|
+
-----------
|
|
37
|
+
Change the workspace and database in the notebook.
|
|
38
|
+
|
|
39
|
+
Arguments
|
|
40
|
+
---------
|
|
41
|
+
* ``<workspace-id>``: The ID of the workspace to delete.
|
|
42
|
+
* ``<workspace-name>``: The name of the workspace to delete.
|
|
43
|
+
|
|
44
|
+
Remarks
|
|
45
|
+
-------
|
|
46
|
+
* If you want to specify a database in the current workspace,
|
|
47
|
+
the workspace name can be specified as ``@@CURRENT``.
|
|
48
|
+
* Specify the ``WITH DATABASE`` clause to select a default
|
|
49
|
+
database for the session.
|
|
50
|
+
* This command only works in a notebook session in the
|
|
51
|
+
Managed Service.
|
|
52
|
+
|
|
53
|
+
Example
|
|
54
|
+
-------
|
|
55
|
+
The following command sets the workspace to ``examplews`` and
|
|
56
|
+
select 'dbname' as the default database::
|
|
57
|
+
|
|
58
|
+
USE WORKSPACE 'examplews' WITH DATABASE 'dbname';
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
|
|
62
|
+
from singlestoredb.notebook import portal
|
|
63
|
+
if params['workspace'].get('current_workspace'):
|
|
64
|
+
if params.get('with_database'):
|
|
65
|
+
portal.default_database = params['with_database']
|
|
66
|
+
elif params.get('with_database'):
|
|
67
|
+
if params['workspace'].get('workspace_name'):
|
|
68
|
+
portal.connection = params['workspace']['workspace_name'], \
|
|
69
|
+
params['with_database']
|
|
70
|
+
else:
|
|
71
|
+
portal.connection = params['workspace']['workspace_id'], \
|
|
72
|
+
params['with_database']
|
|
73
|
+
elif params['workspace'].get('workspace_name'):
|
|
74
|
+
portal.workspace = params['workspace']['workspace_name']
|
|
75
|
+
else:
|
|
76
|
+
portal.workspace = params['workspace']['workspace_id']
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
UseWorkspaceHandler.register(overwrite=True)
|
|
81
|
+
|
|
82
|
+
|
|
16
83
|
class ShowRegionsHandler(SQLHandler):
|
|
17
84
|
"""
|
|
18
85
|
SHOW REGIONS [ <like> ]
|
|
@@ -416,8 +483,9 @@ class CreateWorkspaceHandler(SQLHandler):
|
|
|
416
483
|
size = '<size>'
|
|
417
484
|
|
|
418
485
|
# Auto-suspend
|
|
419
|
-
auto_suspend = AUTO SUSPEND
|
|
420
|
-
|
|
486
|
+
auto_suspend = AUTO SUSPEND AFTER suspend_after_value suspend_after_units suspend_type
|
|
487
|
+
suspend_after_value = <integer>
|
|
488
|
+
suspend_after_units = { SECONDS | MINUTES | HOURS | DAYS }
|
|
421
489
|
suspend_type = WITH TYPE { IDLE | SCHEDULED | DISABLED }
|
|
422
490
|
|
|
423
491
|
# Enable Kai
|
|
@@ -442,7 +510,7 @@ class CreateWorkspaceHandler(SQLHandler):
|
|
|
442
510
|
in which the workspace is created.
|
|
443
511
|
* ``<workspace_size>``: The size of the workspace in workspace size notation,
|
|
444
512
|
for example "S-1".
|
|
445
|
-
* ``<suspend_time>``: The time (in
|
|
513
|
+
* ``<suspend_time>``: The time (in given units) after which the workspace is
|
|
446
514
|
suspended, according to the specified auto-suspend type.
|
|
447
515
|
* ``<multiplier>``: The multiplier for the persistent cache associated with
|
|
448
516
|
the workspace.
|
|
@@ -486,9 +554,17 @@ class CreateWorkspaceHandler(SQLHandler):
|
|
|
486
554
|
|
|
487
555
|
auto_suspend = None
|
|
488
556
|
if params['auto_suspend']:
|
|
557
|
+
mult = dict(
|
|
558
|
+
SECONDS=1,
|
|
559
|
+
MINUTES=60,
|
|
560
|
+
HOURS=60*60,
|
|
561
|
+
DAYS=60*60*24,
|
|
562
|
+
)
|
|
563
|
+
val = params['auto_suspend'][0]['suspend_after_value']
|
|
564
|
+
val = val * mult[params['auto_suspend'][1]['suspend_after_units'].upper()]
|
|
489
565
|
auto_suspend = dict(
|
|
490
|
-
suspend_after_seconds=
|
|
491
|
-
suspend_type=params['auto_suspend'][
|
|
566
|
+
suspend_after_seconds=val,
|
|
567
|
+
suspend_type=params['auto_suspend'][2]['suspend_type'].upper(),
|
|
492
568
|
)
|
|
493
569
|
|
|
494
570
|
workspace_group.create_workspace(
|
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()))
|