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