mysqlx.Schema

class mysqlx.Schema(session, name)

Bases: mysqlx.crud.DatabaseObject

A client-side representation of a database schema. Provides access to the schema contents.

Parameters
  • session (mysqlx.XSession) – Session object.

  • name (str) – The Schema name.

am_i_real()

Verifies if this object exists in the database.

Returns

True if object exists in database.

Return type

bool

Raises

NotImplementedError – This method must be implemented.

Deprecated since version 8.0.12: Use exists_in_database() method instead.

create_collection(name, reuse_existing=False, validation=None, **kwargs)

Creates in the current schema a new collection with the specified name and retrieves an object representing the new collection created.

Parameters
  • name (str) – The name of the collection.

  • reuse_existing (bool) – True to reuse an existing collection.

  • validation (Optional[dict]) – A dict, containing the keys level with the validation level and schema with a dict or a string representation of a JSON schema specification.

Returns

Collection object.

Return type

mysqlx.Collection

Raises

Changed in version 8.0.21.

drop_collection(name)

Drops a collection.

Parameters

name (str) – The name of the collection to be dropped.

exists_in_database()

Verifies if this object exists in the database.

Returns

True if object exists in database.

Return type

bool

get_collection(name, check_existence=False)

Returns the collection of the given name for this schema.

Returns

Collection object.

Return type

mysqlx.Collection

get_collection_as_table(name, check_existence=False)

Returns a a table object for the given collection

Returns

Table object.

Return type

mysqlx.Table

get_collections()

Returns a list of collections for this schema.

Returns

List of Collection objects.

Return type

list

get_connection()

Returns the underlying connection.

Returns

The connection object.

Return type

mysqlx.connection.Connection

get_name()

Returns the name of this database object.

Returns

The name of this database object.

Return type

str

get_schema()

Returns the Schema object of this database object.

Returns

The Schema object.

Return type

mysqlx.Schema

get_session()

Returns the session of this database object.

Returns

The Session object.

Return type

mysqlx.Session

get_table(name, check_existence=False)

Returns the table of the given name for this schema.

Returns

Table object.

Return type

mysqlx.Table

get_tables()

Returns a list of tables for this schema.

Returns

List of Table objects.

Return type

list

get_view(name, check_existence=False)

Returns the view of the given name for this schema.

Returns

View object.

Return type

mysqlx.View

modify_collection(name, validation=None)

Modifies a collection using a JSON schema validation.

Parameters
  • name (str) – The name of the collection.

  • validation (Optional[dict]) – A dict, containing the keys level with the validation level and schema with a dict or a string representation of a JSON schema specification.

Raises

New in version 8.0.21.

property name

The name of this database object.

Type

str

property schema

The Schema object.

Type

mysqlx.Schema

property session

The Session object.

Type

mysqlx.Session

who_am_i()

Returns the name of this database object.

Returns

The name of this database object.

Return type

str

Deprecated since version 8.0.12: Use get_name() method instead.