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(*args, **kwargs)

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=False)

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 (bool) – True to reuse an existing collection.
Returns:

Collection object.

Return type:

mysqlx.Collection

Raises:

mysqlx.ProgrammingError – If reuse is False and collection exists.

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
name

str – The name of this database object.

schema

mysqlx.Schema – The Schema object.

session

mysqlx.Session – The Session object.

who_am_i(*args, **kwargs)

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.