Functions

The function module defines four classes: class Proc derived from DbSchemaObject, classes Function and Aggregate derived from Proc, and class ProcDict derived from DbObject.

Procedure

Class Proc is derived from DbSchemaObject and represents a regular or aggregate function.

class pyrseas.dbobject.function.Proc(name, schema, description, owner, privileges, arguments)

A procedure such as a FUNCTION or an AGGREGATE

Proc.extern_key()

Return the key to be used in external maps for this function

Returns:string
Proc.identifier()

Return a full identifier for a function object

Returns:string

Function

Function is derived from Proc and represents a PostgreSQL user-defined function.

class pyrseas.dbobject.function.Function(name, schema, description, owner, privileges, arguments, language, returns, source, obj_file=None, configuration=None, volatility=None, leakproof=False, strict=False, security_definer=False, cost=0, rows=0, allargs=None, oid=None)

A procedural language function

Function.to_map(db, no_owner, no_privs)

Convert a function to a YAML-suitable format

Parameters:
  • no_owner – exclude function owner information
  • no_privs – exclude privilege information
Returns:

dictionary

Function.create(obj, *args, **kwargs)

Return SQL statements to CREATE or REPLACE the function

Parameters:newsrc – new source for a changed function
Returns:SQL statements

Aggregate Function

Aggregate is derived from Proc and represents a PostgreSQL user-defined aggregate function.

class pyrseas.dbobject.function.Aggregate(name, schema, description, owner, privileges, arguments, sfunc=None, stype=None, finalfunc=None, initcond=None, sortop=None, oid=None)

An aggregate function

Aggregate.to_map(db, no_owner, no_privs)

Convert an agggregate to a YAML-suitable format

Parameters:
  • no_owner – exclude aggregate owner information
  • no_privs – exclude privilege information
Returns:

dictionary

Aggregate.create(obj, *args, **kwargs)

Return SQL statements to CREATE the aggregate

Returns:SQL statements

Procedure Dictionary

ProcDict is derived from DbObjectDict. It is a dictionary that represents the collection of regular and aggregate functions in a database.

class pyrseas.dbobject.function.ProcDict(dbconn=None)

The collection of regular and aggregate functions in a database

ProcDict.from_map(schema, infuncs)

Initalize the dictionary of functions by converting the input map

Parameters:
  • schema – schema owning the functions
  • infuncs – YAML map defining the functions