Rules

The rule module defines two classes, Rule and RuleDict, derived from DbSchemaObject and DbObjectDict, respectively.

Rule

Rule is derived from DbSchemaObject and represents a PostgreSQL rewrite rule.

class pyrseas.dbobject.rule.Rule(schema, name, description=None, owner=None, privileges=None, **attrs)

A rewrite rule definition

Rule.identifier()

Return a full identifier for a rule object

Returns:string
Rule.to_map()

Convert rule to a YAML-suitable format

Returns:dictionary
Rule.create(obj, *args, **kwargs)

Return SQL statements to CREATE the rule

Returns:SQL statements

Rule Dictionary

RuleDict is derived from DbObjectDict. It is a dictionary that represents the collection of rewrite rules in a database.

class pyrseas.dbobject.rule.RuleDict(dbconn=None)

The collection of rewrite rules in a database.

RuleDict.from_map(table, inmap)

Initialize the dictionary of rules by examining the input map

Parameters:inmap – the input YAML map defining the rules
RuleDict.diff_map(inrules)

Generate SQL to transform existing rules

Parameters:input_map – a YAML map defining the new rules
Returns:list of SQL statements

Compares the existing rule definitions, as fetched from the catalogs, to the input map and generates SQL statements to transform the rules accordingly.