Database Objects
The dbobject module defines two low-level classes and an intermediate class. Most Pyrseas classes are derived from either DbObject or DbObjectDict.
Database Object
A DbObject represents a database object such as a schema, table, or column, defined in a Postgres 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.
The following methods are generally used to map objects for external output:
The following methods generate SQL statements from the object properties and sometimes from a second object:
Database Object Dictionary
A DbObjectDict represents a collection of DbObject's and is derived from the Python built-in type dict. If a ~pyrseas.lib.dbconn.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 method defined by derived classes. Derived classes should also define a cls attribute for the associated DbObject class, e.g., ~pyrseas.schema.SchemaDict sets cls to ~pyrseas.schema.Schema.
Schema Object
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 ~pyrseas.schema.Schema that represents the schema (Postgres namespace) itself.