mysqlx.Session¶
- class mysqlx.Session(settings: Dict[str, Any])¶
Bases:
object
Enables interaction with a X Protocol enabled MySQL Product.
The functionality includes:
Accessing available schemas.
Schema management operations.
Retrieval of connection information.
- Parameters:
settings (dict) – Connection data used to connect to the database.
- close() None ¶
Closes the session.
- close_connections() None ¶
Closes all underliying connections as pooled connections
- commit() None ¶
Commits all the operations executed after a call to startTransaction().
- create_schema(name: str) Schema ¶
Creates a schema on the database and returns the corresponding object.
- Parameters:
name (string) – A string value indicating the schema name.
- drop_schema(name: str) None ¶
Drops the schema with the specified name.
- Parameters:
name (string) – The name of the Schema object to be retrieved.
- get_connection() Connection ¶
Returns the underlying connection.
- Returns:
The connection object.
- Return type:
mysqlx.connection.Connection
- get_default_schema() Schema | None ¶
Retrieves a Schema object from the current session by the schema name configured in the connection settings.
- Returns:
- The Schema object with the given name at connect
time.
- None: In case the default schema was not provided with the
initialization data.
- Return type:
- Raises:
mysqlx.ProgrammingError – If the provided default schema does not exists.
- get_schema(name: str) Schema ¶
Retrieves a Schema object from the current session by it’s name.
- Parameters:
name (string) – The name of the Schema object to be retrieved.
- Returns:
The Schema object with the given name.
- Return type:
- get_schemas() List[str] ¶
Returns the list of schemas in the current session.
- Returns:
The list of schemas in the current session.
- Return type:
list
New in version 8.0.12.
- is_open() bool ¶
Returns True if the session is open.
- Returns:
Returns True if the session is open.
- Return type:
bool
- release_savepoint(name: str) None ¶
Release a transaction savepoint with the given name.
- Parameters:
name (string) – The savepoint name.
- rollback() None ¶
Discards all the operations executed after a call to startTransaction().
- rollback_to(name: str) None ¶
Rollback to a transaction savepoint with the given name.
- Parameters:
name (string) – The savepoint name.
- set_savepoint(name: str | None = None) str ¶
Creates a transaction savepoint.
If a name is not provided, one will be generated using the uuid.uuid1() function.
- Parameters:
name (Optional[string]) – The savepoint name.
- Returns:
The savepoint name.
- Return type:
string
- sql(sql: str) SqlStatement ¶
Creates a
mysqlx.SqlStatement
object to allow running the SQL statement on the target MySQL Server.- Parameters:
sql (string) – The SQL statement to be executed.
- Returns:
SqlStatement object.
- Return type:
- start_transaction() None ¶
Starts a transaction context on the server.
- property use_pure: bool¶
True to use pure Python Protobuf implementation.
- Type:
bool