Columns¶
The column module defines two classes, Column derived
from DbSchemaObject and ColumnDict, derived from
DbObjectDict.
Column¶
Column is derived from
DbSchemaObject and represents a column of a
table, or an attribute of a composite type. Its keylist
attributes are the schema name and the table name.
A Column has the following attributes: name,
type, not_null, default and
collation. The number attribute is also present but is
not made visible externally.
-
class
pyrseas.dbobject.column.Column(name, schema, table, number, type, description=None, privileges=[], not_null=True, default=None, identity=None, collation=None, statistics=None, inherited=False, dropped=False)¶ A table column or attribute of a composite type
-
Column.to_map(db, no_privs)¶ Convert a column to a YAML-suitable format
Parameters: no_privs – exclude privilege information Returns: dictionary
-
Column.add()¶ Return a string to specify the column in a CREATE or ALTER TABLE
Returns: partial SQL statement
-
Column.add_privs()¶ Generate SQL statements to grant privileges on new column
Returns: list of SQL statements
-
Column.diff_privileges(incol)¶ Generate SQL statements to grant or revoke privileges
Parameters: incol – a YAML map defining the input column Returns: list of SQL statements
-
Column.comment()¶ Return a SQL COMMENT statement for the column
Returns: SQL statement
-
Column.drop()¶ Return string to drop the column via ALTER TABLE
Returns: SQL statement
-
Column.rename(newname)¶ Return SQL statement to RENAME the column
Parameters: newname – the new name of the object Returns: SQL statement
-
Column.alter(incol)¶ Generate SQL to transform an existing column
Parameters: insequence – a YAML map defining the new column Returns: list of partial SQL statements Compares the column to an input column and generates partial SQL statements to transform it into the one represented by the input.
Column Dictionary¶
Class ColumnDict is a dictionary derived from
DbObjectDict and represents the collection
of columns in a database, across multiple tables. It is indexed by the
schema name and table name, and each value is a list of
Column objects.
-
class
pyrseas.dbobject.column.ColumnDict(dbconn=None)¶ The collection of columns in tables in a database
-
ColumnDict.from_map(table, incols)¶ Initialize the dictionary of columns by converting the input list
Parameters: - table – table or type owning the columns/attributes
- incols – YAML list defining the columns