A DbObject represents a database object such as a schema, table, or column, defined in a PostgreSQL system catalog. It is initialized from a dictionary of attributes. Derived classes should define a keylist that is a list of attribute names that uniquely identify each object instance within the database.
A single object in a database catalog, e.g., a schema, a table, a column
Type of object as an uppercase string, for SQL syntax generation
This is used in most CREATE, ALTER and DROP statements. It is also used by extern_key() in lowercase form.
Return the key to be used in external maps for this object
This is used for the first two levels of external maps. The first level is the one that includes schemas, as well as extensions, languages, casts and FDWs. The second level includes all schema-owned objects, i.e., tables, functions, operators, etc. All subsequent levels, e.g., primary keys, indexes, etc., currently use the object name as the external identifier, appearing in the map after an object grouping header, such as primary_key.
The common format for an external key is object-type non-schema-qualified-name, where object-type is the lowercase version of objtype, e.g., table tablename. Some object types require more, e.g., functions need the signature, so they override this implementation.
List of attributes that uniquely identify the object in the catalogs
See description of key() for further details.
Return a tuple that identifies the database object
|Returns:||a single string or a tuple of strings|
This is used as key for all internal maps. The first-level objects (schemas, languages and casts) use the object name as the key. Second-level (schema-owned) objects usually use the schema name and the object name as the key. Some object types need longer keys, e.g., operators need schema name, operator symbols, left argument and right argument.
Each class implementing an object type specifies a keylist attribute, i.e., a list giving the names of attributes making up the key.
Returns a full identifier for the database object
This is used by comment(), alter_owner() and drop() to generate SQL syntax referring to the object. It does not include the object type, but it may include (in overriden methods) other elements, e.g., the arguments to a function.
Convert an object to a YAML-suitable format
Return a list of access privileges on the current object
Return SQL statement to create a COMMENT on the object
Return ALTER statement to set the OWNER of an object
Return SQL statement to DROP the object
Return SQL statement to RENAME the object
|Parameters:||newname – the new name for the object|
Generate SQL statements to add or change COMMENTs
|Parameters:||inobj – a YAML map defining the input object|
|Returns:||list of SQL statements|
A DbObjectDict represents a collection of DbObject‘s and is derived from the Python built-in type dict. If a DbConnection object is used for initialization, an internal method is called to initialize the dictionary from the database catalogs. The DbObjectDict fetch() method fetches all objects using the query defined by derived classes. Derived classes should also define a cls attribute for the associated DbObject class, e.g., SchemaDict sets cls to Schema.
A dictionary of database objects, all of the same type
The class, derived from DbObject that the objects belong to.
The SQL SELECT query to fetch object instances from the catalogs
This is used by the method fetch().
A DbSchemaObject is derived from DbObject. It is used as a base class for objects owned by a schema and to define certain common methods. This is different from the Schema that represents the schema itself.
A database object that is owned by a certain schema
Return a full identifier for a schema object
Return the schema-qualified name of the object
No qualification is used if the schema is ‘public’.
Adjust the schema and table name if the latter is qualified
Return a SQL DROP statement for the schema object
Return a SQL ALTER statement to RENAME the schema object
|Parameters:||newname – the new name of the object|
Return a SQL SET search_path if not in the ‘public’ schema