mysqlx.Session

class mysqlx.Session(settings)

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()

Closes the session.

close_connections()

Closes all underliying connections as pooled connections

commit()

Commits all the operations executed after a call to startTransaction().

create_schema(name)

Creates a schema on the database and returns the corresponding object.

Parameters:

name (string) – A string value indicating the schema name.

drop_schema(name)

Drops the schema with the specified name.

Parameters:

name (string) – The name of the Schema object to be retrieved.

get_connection()

Returns the underlying connection.

Returns:

The connection object.

Return type:

mysqlx.connection.Connection

get_default_schema()

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:

mysqlx.Schema

Raises:

mysqlx.ProgrammingError – If the provided default schema does not exists.

get_schema(name)

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:

mysqlx.Schema

get_schemas()

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()

Returns True if the session is open.

Returns:

Returns True if the session is open.

Return type:

bool

release_savepoint(name)

Release a transaction savepoint with the given name.

Parameters:

name (string) – The savepoint name.

rollback()

Discards all the operations executed after a call to startTransaction().

rollback_to(name)

Rollback to a transaction savepoint with the given name.

Parameters:

name (string) – The savepoint name.

set_savepoint(name=None)

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)

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:

mysqlx.SqlStatement

start_transaction()

Starts a transaction context on the server.

property use_pure

True to use pure Python Protobuf implementation.

Type:

bool