API Reference¶
Connections¶
The connect()
function is the primary entry point for the SingleStore
package. It connects to a SingleStore database using either
DB-API compliant parameters,
or a connection string in the form of a URL.
The create_engine()
function is used with the SQLAlchemy package
to create an SQLAlchemy engine for SingleStoreDB connections. This is
primarily for use in environments where the connection parameters are
stored in environment variables so that you can create SingleStoreDB
connections without specifying any parameters in the code itself.
|
Return a SingleStoreDB connection. |
|
Create an SQLAlchemy engine for SingleStoreDB. |
Connection¶
Connection objects are created by the singlestoredb.connect()
function. They are
used to create Cursor
objects for querying the database.
|
SingleStoreDB connection. |
|
Set autocommit mode. |
Close the database connection. |
|
Commit the pending transaction. |
|
Rollback the pending transaction. |
|
Create a new cursor object. |
|
Determine if the database is still connected. |
|
|
Enable the data API in the server. |
Disable the data API. |
The Connection.show
attribute of the connection objects allow you to access various
information about the server. The available operations are shown below.
Show all aggregate functions in the current database. |
|
|
Show the column information for the given table. |
Show the function creation code for the given aggregate function. |
|
Show the function creation code for the given function. |
|
|
Show the pipeline creation code for the given pipeline. |
Show the table creation code for the given table. |
|
Show the view creation code for the given view. |
|
|
Show all databases in the server. |
Show status of the current database. |
|
Show errors. |
|
Show all functions in the current database. |
|
Show global status of the current server. |
|
|
Show all indexes in the given table. |
|
Show partitions in the current database. |
Show all pipelines in the current database. |
|
|
Show the plan for the given plan ID. |
Show all query statements compiled and executed. |
|
Show all procedures in the current database. |
|
Show details about currently running threads. |
|
|
Show troubleshooting data for query optimizer and code generation. |
Show schemas in the server. |
|
Show server status information for a session. |
|
|
Show server status information. |
Show table status information for the current database. |
|
|
Show tables in the current database. |
Show warnings. |
ShowResult¶
The results of the above methods and attributes are in the form of a
ShowResult
object. This object is primarily used to display
information to the screen or web browser, but columns from the output
can also be accessed using dictionary-like key access syntax or
attributes.
|
Simple result object. |
Cursor¶
Cursors are used to query the database and download results. They are
created using the Connection.cursor()
method.
|
Database cursor for submitting commands and queries. |
|
Call a stored procedure. |
Close the cursor. |
|
|
Execute a SQL statement. |
|
Execute SQL code against multiple sets of parameters. |
Fetch a single row from the result set. |
|
|
Fetch size rows from the result. |
Fetch all rows in the result set. |
|
Skip to the next available result set. |
|
|
Predefine memory areas for parameters. |
|
Set a column buffer size for fetches of large columns. |
|
Scroll the cursor to the position in the result set. |
Return the next row from the result set for use in iterators. |
|
Is the cursor still connected? |
Utilities¶
|
Retrieve a JWT token from the SingleStoreDB single-sign-on URL. |
Management API¶
The management objects allow you to create, destroy, and interact with workspaces in the SingleStoreDB Cloud.
The manage_workspaces()
function will return a WorkspaceManager
object that can be used to interact with the Management API.
|
Retrieve a SingleStoreDB workspace manager. |
WorkspaceManager¶
WorkspaceManager objects are returned by the manage_workspaces()
function.
They allow you to retrieve information about workspaces in your account, or
create new ones.
|
SingleStoreDB workspace manager. |
Return the current organization. |
|
Return a list of available workspace groups. |
|
Return a list of available regions. |
|
Create a new workspace group. |
|
|
Create a new workspace. |
Retrieve a workspace group definition. |
|
Retrieve a workspace definition. |
WorkspaceGroup¶
WorkspaceGroup objects are retrieved from WorkspaceManager.get_workspace_group()
or by retrieving an element from WorkspaceManager.workspace_groups
.
|
SingleStoreDB workspace group definition. |
Return a list of available workspaces. |
|
Stage manager. |
|
|
Create a new workspace. |
Update the object to the current state. |
|
|
Update the workspace group definition. |
|
Terminate the workspace group. |
Workspace¶
Workspaces are created within WorkspaceGroups. They can be created using either
WorkspaceGroup.create_workspace()
or retrieved from
WorkspaceManager.workspaces
.
|
SingleStoreDB workspace definition. |
|
Create a connection to the database server for this workspace. |
Update the object to the current state. |
|
|
Update the workspace definition. |
|
Terminate the workspace. |
Region¶
Region objects are accessed from the WorkspaceManager.regions
attribute.
|
Cluster region information. |
Stage¶
To interact with Stage, use the WorkspaceManager.stage
attribute.
It will return a Stage
object which defines the following
methods and attributes.
|
Stage manager. |
|
Open a Stage path for reading or writing. |
|
Download the content of a stage path. |
|
Download a Stage folder to a local directory. |
|
Upload a local file. |
|
Upload a folder recursively. |
|
Return information about a stage location. |
|
List the files / folders at the given path. |
|
Does the given stage path exist? |
|
Is the given stage path a directory? |
|
Is the given stage path a file? |
|
Make a directory in the stage. |
|
Move the stage file to a new location. |
|
Delete a stage location. |
|
Delete a stage folder recursively. |
|
Delete a stage folder. |
StageObject¶
StageObject`s are returned by the :meth:`StageObject.upload_file
StageObject.upload_folder()
, StageObject.mkdir()
,
StageObject.rename()
, and StageObject.info()
methods.
|
Stage file / folder object. |
|
Open a Stage path for reading or writing. |
|
Download the content of a stage path. |
Does the file / folder exist? |
|
Is the stage object a directory? |
|
Is the stage object a file? |
|
Return the full path of the object. |
|
Return the basename of the object. |
|
Return the directory name of the object. |
|
Return the last modified datetime as a UNIX timestamp. |
|
Return the creation datetime as a UNIX timestamp. |
|
|
Move the stage file to a new location. |
Delete the stage file. |
|
Delete the stage directory recursively. |
|
Delete the empty stage directory. |
Notebook Tools¶
The SDK includes a notebook sub-module for tools that are for use in the SingleStore Managed Service Portal Notebooks environment. The following objects in sinlgestoredb.notebook are singletons that automatically track the organization, workspace group, workspace, stage, and secrets that are selected in the portal.
These objects act just like the corresponding objects discussed in previous of this documentation (including attributes and methods), but they proxy all calls to the currently selected portal services.
Organization in SingleStoreDB Cloud portal. |
|
Wrapper for accessing secrets as object attributes. |
|
SingleStoreDB workspace group definition. |
|
Stage manager. |
|
SingleStoreDB workspace definition. |
Configuration¶
The following functions are used to get and set package configuration settings.
Execute the describe_option()
function with no parameters to
see the documentation for all options.
|
Get the value of an option. |
|
Set the value of an option. |
|
Print the description of one or more options. |
In addition to the function above, you can access options through the
singlestoredb.options
object. This gives you attribute-like access to the option
values.
In [1]: import singlestoredb as s2
In [2]: s2.describe_option('local_infile')
local_infile : bool
Should it be possible to load local files?
[default: False] [currently: False]
In [3]: s2.options.local_infile
Out[3]: False
In [4]: s2.options.local_infile = True
In [5]: s2.describe_option('local_infile')
local_infile : bool
Should it be possible to load local files?
[default: False] [currently: True]