The column module defines two classes, Column derived from DbSchemaObject and ColumnDict, derived from DbObjectDict.


Column is derived from DbSchemaObject and represents a column in a table, or an attribute in a composite type. Its keylist attributes are the schema name and the table name.

A Column has the following attributes: name, type, not_null and default. The number attribute is also present but is not made visible externally.

class pyrseas.dbobject.column.Column(name, schema='public', description=None, **attrs)

A table column definition

Column.to_map(db, no_privs)

Convert a column to a YAML-suitable format

Parameters:no_privs – exclude privilege information

Return a string to specify the column in a CREATE or ALTER TABLE

Returns:partial SQL statement

Generate SQL statements to grant privileges on new column

Returns:list of SQL statements

Generate SQL statements to grant or revoke privileges

Parameters:incol – a YAML map defining the input column
Returns:list of SQL statements

Return a SQL COMMENT statement for the column

Returns:SQL statement

Return string to drop the column via ALTER TABLE

Returns:SQL statement

Return SQL statement to RENAME the column

Parameters:newname – the new name of the object
Returns:SQL statement

Return SQL statements to set a nextval() DEFAULT

Returns:list of SQL statements

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

  • table – table or type owning the columns/attributes
  • incols – YAML list defining the columns