MySQL Shell API 8.0.40
Unified development interface for MySQL Products
|
Represents a Schema as retrieved from a session created using the X Protocol. More...
Methods | |
list | get_tables () |
Returns a list of Tables for this Schema. More... | |
list | get_collections () |
Returns a list of Collections for this Schema. More... | |
Table | get_table (str name) |
Returns the Table of the given name for this schema. More... | |
Collection | get_collection (str name) |
Returns the Collection of the given name for this schema. More... | |
Table | get_collection_as_table (str name) |
Returns a Table object representing a Collection on the database. More... | |
Collection | create_collection (str name, dict options) |
Creates in the current schema a new collection with the specified name and retrieves an object representing the new collection created. More... | |
None | modify_collection (str name, dict options) |
Modifies the schema validation of a collection. More... | |
None | drop_collection (str name) |
Drops the specified collection. More... | |
Methods inherited from DatabaseObject | |
str | get_name () |
Returns the name of this database object.
| |
object | get_session () |
Returns the Session object of this database object.
| |
object | get_schema () |
Returns the Schema object of this database object.
| |
bool | exists_in_database () |
Verifies if this object exists in the database.
| |
Additional Inherited Members | |
Properties inherited from DatabaseObject | |
str | name |
The name of this database object. | |
object | session |
The Session object of this database object. | |
object | schema |
The Schema object of this database object. | |
Represents a Schema as retrieved from a session created using the X Protocol.
View Support
MySQL Views are stored queries that when executed produce a result set.
MySQL supports the concept of Updatable Views: in specific conditions are met, Views can be used not only to retrieve data from them but also to update, add and delete records.
For the purpose of this API, Views behave similar to a Table, and so they are treated as Tables.
Tables and Collections as Properties
A Schema object may expose tables and collections as properties, this way they can be accessed as:
This handy way of accessing tables and collections is available if they met the following conditions:
If any of the conditions is not met, the way to access the table or collection is by using the standard DevAPI functions:
list get_tables | ( | ) |
list get_collections | ( | ) |
Returns a list of Collections for this Schema.
Pulls from the database the available Tables, Views and Collections.
Does a full refresh of the Tables, Views and Collections cache.
Returns a List of available Collection objects.
Table get_table | ( | str | name | ) |
Collection get_collection | ( | str | name | ) |
Returns the Collection of the given name for this schema.
name | the name of the Collection to look for. |
Verifies if the requested Collection exist on the database, if exists, returns the corresponding Collection object.
Updates the Collections cache.
Collection get_collection_as_table | ( | str | name | ) |
Returns a Table object representing a Collection on the database.
name | the name of the collection to be retrieved as a table. |
Collection create_collection | ( | str | name, |
dict | options | ||
) |
Creates in the current schema a new collection with the specified name and retrieves an object representing the new collection created.
name | the name of the collection. |
options | optional dictionary with options. |
To specify a name for a collection, follow the naming conventions in MySQL.
The options dictionary may contain the following attributes:
The validation object allows the following attributes:
None modify_collection | ( | str | name, |
dict | options | ||
) |
Modifies the schema validation of a collection.
name | the name of the collection. |
options | dictionary with options. |
The options dictionary may contain the following attributes:
The validation object allows the following attributes:
None drop_collection | ( | str | name | ) |
Drops the specified collection.