singlestoredb 1.4.3__cp38-abi3-win32.whl → 1.6.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.

@@ -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 suspend_after_seconds SECONDS suspend_type
420
- suspend_after_seconds = AFTER <integer>
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 seconds) after which the workspace is
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=params['auto_suspend'][0]['suspend_after_seconds'],
491
- suspend_type=params['auto_suspend'][-1]['suspend_type'].upper(),
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(
@@ -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()))