MySQL Shell API 9.4.0
Unified development interface for MySQL Products
|
Enables interaction with a MySQL Server using the MySQL Protocol. More...
Methods | |
str | get_uri () |
Retrieves the URI for the current session. More... | |
str | get_ssh_uri () |
Retrieves the SSH URI for the current session. More... | |
str | get_sql_mode () |
Retrieves the SQL_MODE for the current session. More... | |
str | get_connection_id () |
Retrieves the connection id for the current session. More... | |
ClassicResult | run_sql (str query, list args=[]) |
Executes a query and returns the corresponding ClassicResult object. More... | |
None | close () |
Closes the internal connection to the MySQL Server held on this session object. | |
ClassicResult | start_transaction () |
Starts a transaction context on the server. More... | |
ClassicResult | commit () |
Commits all the operations executed after a call to start_transaction(). More... | |
ClassicResult | rollback () |
Discards all the operations executed after a call to start_transaction(). More... | |
bool | is_open () |
Returns true if session is known to be open. More... | |
None | set_query_attributes (dict attributes) |
Defines query attributes that apply to the next statement sent to the server for execution. More... | |
None | set_client_data (str key, Any value) |
Associates a value with the session for the given key. More... | |
Any | get_client_data (str key) |
Returns value associated with the session for the given key. More... | |
str | track_system_variable (str variable) |
Enables session tracking of the given system variable. More... | |
Properties | |
str | uri |
Retrieves the URI for the current session. | |
str | ssh_uri |
Retrieves the SSH URI for the current session. | |
int | connection_id |
Retrieves the connection id for the current session. | |
Enables interaction with a MySQL Server using the MySQL Protocol.
Provides facilities to execute queries.
str get_uri | ( | ) |
Retrieves the URI for the current session.
str get_ssh_uri | ( | ) |
Retrieves the SSH URI for the current session.
str get_sql_mode | ( | ) |
Retrieves the SQL_MODE for the current session.
Queries the value of the SQL_MODE session variable. If session tracking of SQL_MODE is enabled, it will fetch its cached value.
int get_connection_id | ( | ) |
Retrieves the connection id for the current session.
ClassicResult run_sql | ( | str | query, |
list | args = [] |
||
) |
Executes a query and returns the corresponding ClassicResult object.
query | the SQL query to execute against the database. |
args | Optional list of literals to use when replacing ? placeholders in the query string. |
LogicError | if there's no open session. |
ArgumentError | if the parameters are invalid. |
void start_transaction | ( | ) |
Starts a transaction context on the server.
Calling this function will turn off the autocommit mode on the server.
All the operations executed after calling this function will take place only when commit() is called.
All the operations executed after calling this function, will be discarded if rollback() is called.
When commit() or rollback() are called, the server autocommit mode will return back to it's state before calling start_transaction().
void commit | ( | ) |
Commits all the operations executed after a call to start_transaction().
All the operations executed after calling start_transaction() will take place when this function is called.
The server autocommit mode will return back to it's state before calling start_transaction().
void rollback | ( | ) |
Discards all the operations executed after a call to start_transaction().
All the operations executed after calling start_transaction() will be discarded when this function is called.
The server autocommit mode will return back to it's state before calling start_transaction().
bool is_open | ( | ) |
Returns true if session is known to be open.
Returns true if the session is still open and false otherwise.
None set_query_attributes | ( | dict | attributes | ) |
Defines query attributes that apply to the next statement sent to the server for execution.
It is possible to define up to 32 pairs of attribute and values for the next executed SQL statement.
To access query attributes within SQL statements for which attributes have been defined, the query_attributes component must be installed, this component implements a mysql_query_attribute_string() loadable function that takes an attribute name argument and returns the attribute value as a string, or NULL if the attribute does not exist.
To install the query_attributes component execute the following statement:
None set_client_data | ( | str | key, |
Any | value | ||
) |
Associates a value with the session for the given key.
key | (string) A string to identify the stored value. |
value | JSON-like value to be stored. |
Saves a value in the session data structure associated to the given key. The value can be retrieved later using get_client_data().
Any get_client_data | ( | str | key | ) |
Returns value associated with the session for the given key.
key | (string) A string to identify the stored value. |
Returns a value previously stored in the session data structure associated with set_client_data().
str track_system_variable | ( | str | variable | ) |
Enables session tracking of the given system variable.
variable | Name of the system variable to track. |
Appends the given system variable name to the session_track_system_variables, session variable enabling session tracking of changes to it. Currently supported variables: