firebird.lib.schema¶
Globals¶
- firebird.lib.schema.SCRIPT_DEFAULT_ORDER¶
List of default sections (in order) for
Schema.get_metadata_ddl()
Enums¶
- class firebird.lib.schema.FieldType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Firebird field type codes.
- BLOB = 261¶
- BLOB_ID = 45¶
- BOOLEAN = 23¶
- CSTRING = 40¶
- DATE = 12¶
- DEC16 = 24¶
- DEC34 = 25¶
- DOUBLE = 27¶
- FLOAT = 10¶
- INT128 = 26¶
- INT64 = 16¶
- LONG = 8¶
- NONE = 0¶
- QUAD = 9¶
- SHORT = 7¶
- TEXT = 14¶
- TIME = 13¶
- TIMESTAMP = 35¶
- TIMESTAMP_TZ = 29¶
- TIMESTAMP_TZ_EX = 31¶
- TIME_TZ = 28¶
- TIME_TZ_EX = 30¶
- VARYING = 37¶
- class firebird.lib.schema.FieldSubType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Field sub-types.
- ACL = 3¶
- BINARY = 0¶
- BLR = 2¶
- DEBUG_INFORMATION = 9¶
- DECIMAL = 2¶
- EXTERNAL_FILE_DESCRIPTION = 8¶
- FORMAT = 6¶
- NUMERIC = 1¶
- RANGES = 4¶
- SUMMARY = 5¶
- TEXT = 1¶
- TRANSACTION_DESCRIPTION = 7¶
- class firebird.lib.schema.ObjectType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Dependent type codes.
Changed in version 1.4.0: -
PACKAGE
renamed toPACKAGE_HEADER
, added values 20-37- BLOB_FILTER = 16¶
- CHARACTER_SET = 11¶
- CHARSETS = 31¶
- CHECK = 4¶
- COLLATION = 17¶
- COLLATIONS = 32¶
- COLUMN = 9¶
- DATABASE = 21¶
- DOMAIN = 3¶
- DOMAINS = 28¶
- EXCEPTION = 7¶
- EXCEPTIONS = 29¶
- FILTERS = 33¶
- FUNCTIONS = 25¶
- GENERATOR = 14¶
- GENERATORS = 27¶
- INDEX = 10¶
- INDEX_CONDITION = 37¶
- INDEX_EXPR = 6¶
- JOBS = 34¶
- PACKAGES = 26¶
- PACKAGE_BODY = 19¶
- PACKAGE_HEADER = 18¶
- PRIVILEGE = 20¶
- PROCEDURE = 5¶
- PROCEDURES = 24¶
- RELATIONS = 22¶
- ROLE = 13¶
- ROLES = 30¶
- TABLE = 0¶
- TABLESPACE = 35¶
- TABLESPACES = 36¶
- TRIGGER = 2¶
- UDF = 15¶
- USER = 8¶
- USER_GROUP = 12¶
- VIEW = 1¶
- VIEWS = 23¶
- class firebird.lib.schema.IndexType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Index ordering.
- ASCENDING = 'ASCENDING'¶
- DESCENDING = 'DESCENDING'¶
- class firebird.lib.schema.Mechanism(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Mechanism codes.
- BY_ISC_DESCRIPTOR = 3¶
- BY_REFERENCE = 1¶
- BY_REFERENCE_WITH_NULL = 5¶
- BY_SCALAR_ARRAY_DESCRIPTOR = 4¶
- BY_VALUE = 0¶
- BY_VMS_DESCRIPTOR = 2¶
- class firebird.lib.schema.TransactionState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Transaction state codes.
- COMMITTED = 2¶
- LIMBO = 1¶
- ROLLED_BACK = 3¶
- class firebird.lib.schema.SystemFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
System flag codes.
- CHECK_CONSTRAINT = 3¶
- IDENTITY_GENERATOR = 6¶
- QLI = 2¶
- REFERENTIAL_CONSTRAINT = 4¶
- SYSTEM = 1¶
- USER = 0¶
- VIEW_CHECK = 5¶
- class firebird.lib.schema.RelationType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Relation type codes.
- EXTERNAL = 2¶
- GLOBAL_TEMPORARY_DELETE = 5¶
- GLOBAL_TEMPORARY_PRESERVE = 4¶
- PERSISTENT = 0¶
- VIEW = 1¶
- VIRTUAL = 3¶
- class firebird.lib.schema.ProcedureType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Procedure type codes.
- EXECUTABLE = 2¶
- LEGACY = 0¶
- SELECTABLE = 1¶
- class firebird.lib.schema.ParameterMechanism(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Parameter mechanism type codes.
- NORMAL = 0¶
- TYPE_OF = 1¶
- class firebird.lib.schema.TypeFrom(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Source of parameter datatype codes.
- DATATYPE = 0¶
- DOMAIN = 1¶
- TYPE_OF_COLUMN = 3¶
- TYPE_OF_DOMAIN = 2¶
- class firebird.lib.schema.ParameterType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Parameter type codes.
- INPUT = 0¶
- OUTPUT = 1¶
- class firebird.lib.schema.IdentityType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Identity type codes.
- ALWAYS = 0¶
- BY_DEFAULT = 1¶
- class firebird.lib.schema.GrantOption(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Grant option codes.
- ADMIN_OPTION = 2¶
- GRANT_OPTION = 1¶
- NONE = 0¶
- class firebird.lib.schema.PageType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Page type codes.
- BLOB = 8¶
- DATA = 5¶
- GENERATOR = 9¶
- HEADER = 1¶
- INDEX_BUCKET = 7¶
- INDEX_ROOT = 6¶
- PAGE_INVENTORY = 2¶
- POINTER = 4¶
- SCN_INVENTORY = 10¶
- TRANSACTION_INVENTORY = 3¶
- class firebird.lib.schema.MapTo(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Map to type codes.
- ROLE = 1¶
- USER = 0¶
- class firebird.lib.schema.TriggerType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Trigger type codes.
- DB = 8192¶
- DDL = 16384¶
- DML = 0¶
- class firebird.lib.schema.DDLTrigger(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
DDL trigger type codes.
- ALTER_CHARACTER_SET = 39¶
- ALTER_DOMAIN = 23¶
- ALTER_EXCEPTION = 17¶
- ALTER_FUNCTION = 8¶
- ALTER_INDEX = 29¶
- ALTER_MAPPING = 46¶
- ALTER_PACKAGE = 41¶
- ALTER_PROCEDURE = 5¶
- ALTER_ROLE = 26¶
- ALTER_SEQUENCE = 32¶
- ALTER_TABLE = 2¶
- ALTER_TRIGGER = 11¶
- ALTER_USER = 35¶
- ALTER_VIEW = 20¶
- ANY = 4611686018427375615¶
- CREATE_COLLATION = 37¶
- CREATE_DOMAIN = 22¶
- CREATE_EXCEPTION = 16¶
- CREATE_FUNCTION = 7¶
- CREATE_INDEX = 28¶
- CREATE_MAPPING = 45¶
- CREATE_PACKAGE = 40¶
- CREATE_PACKAGE_BODY = 43¶
- CREATE_PROCEDURE = 4¶
- CREATE_ROLE = 25¶
- CREATE_SEQUENCE = 31¶
- CREATE_TABLE = 1¶
- CREATE_TRIGGER = 10¶
- CREATE_USER = 34¶
- CREATE_VIEW = 19¶
- DROP_COLLATION = 38¶
- DROP_DOMAIN = 24¶
- DROP_EXCEPTION = 18¶
- DROP_FUNCTION = 9¶
- DROP_INDEX = 30¶
- DROP_MAPPING = 47¶
- DROP_PACKAGE = 42¶
- DROP_PACKAGE_BODY = 44¶
- DROP_PROCEDURE = 6¶
- DROP_ROLE = 27¶
- DROP_SEQUENCE = 33¶
- DROP_TABLE = 3¶
- DROP_TRIGGER = 12¶
- DROP_USER = 36¶
- DROP_VIEW = 21¶
- class firebird.lib.schema.DBTrigger(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Database trigger type codes.
- CONNECT = 0¶
- DISCONNECT = 1¶
- TRANSACTION_COMMIT = 3¶
- TRANSACTION_ROLLBACK = 4¶
- TRANSACTION_START = 2¶
- class firebird.lib.schema.TriggerTime(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Trigger action time codes.
- AFTER = 1¶
- BEFORE = 0¶
- class firebird.lib.schema.ConstraintType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Contraint type codes.
- CHECK = 'CHECK'¶
- FOREIGN_KEY = 'FOREIGN KEY'¶
- NOT_NULL = 'NOT NULL'¶
- PRIMARY_KEY = 'PRIMARY KEY'¶
- UNIQUE = 'UNIQUE'¶
- class firebird.lib.schema.Section(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
DDL script sections. Used by
Schema.get_metadata_ddl()
.- CHARACTER_SETS = 2¶
- CHECK_CONSTRAINTS = 13¶
- COLLATIONS = 1¶
- COMMENTS = 23¶
- DOMAINS = 6¶
- EXCEPTIONS = 5¶
- FOREIGN_CONSTRAINTS = 14¶
- FUNCTION_BODIES = 19¶
- FUNCTION_DEFS = 8¶
- GENERATORS = 4¶
- GRANTS = 22¶
- INDEX_ACTIVATIONS = 27¶
- INDEX_DEACTIVATIONS = 26¶
- INDICES = 15¶
- PACKAGE_BODIES = 17¶
- PACKAGE_DEFS = 7¶
- PRIMARY_KEYS = 11¶
- PROCEDURE_BODIES = 18¶
- PROCEDURE_DEFS = 9¶
- ROLES = 21¶
- SET_GENERATORS = 25¶
- SHADOWS = 24¶
- TABLES = 10¶
- TRIGGERS = 20¶
- TRIGGER_ACTIVATIONS = 29¶
- TRIGGER_DEACTIVATIONS = 28¶
- UDFS = 3¶
- UNIQUE_CONSTRAINTS = 12¶
- VIEWS = 16¶
- class firebird.lib.schema.Category(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Schema information collection categories.
- BACKUP_HISTORY = 20¶
- CHARACTER_SETS = 11¶
- COLLATIONS = 10¶
- CONSTRAINTS = 9¶
- DEPENDENCIES = 5¶
- DOMAINS = 3¶
- EXCEPTIONS = 12¶
- FILES = 15¶
- FILTERS = 21¶
- FUNCTIONS = 14¶
- GENERATORS = 6¶
- INDICES = 4¶
- PACKAGES = 19¶
- PRIVILEGES = 17¶
- PROCEDURES = 8¶
- ROLES = 13¶
- SEQUENCES = 6¶
- SHADOWS = 16¶
- TABLES = 1¶
- TRIGGERS = 7¶
- USERS = 18¶
- VIEWS = 2¶
- class firebird.lib.schema.Privacy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Privacy flag codes.
- PRIVATE = 1¶
- PUBLIC = 0¶
- class firebird.lib.schema.Legacy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Legacy flag codes.
- LEGACY_STYLE = 1¶
- NEW_STYLE = 0¶
- class firebird.lib.schema.PrivilegeCode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Priviledge codes.
- ALTER = 'L'¶
- CREATE = 'C'¶
- DELETE = 'D'¶
- DROP = 'O'¶
- EXECUTE = 'X'¶
- INSERT = 'I'¶
- MEMBERSHIP = 'M'¶
- REFERENCES = 'R'¶
- SELECT = 'S'¶
- UPDATE = 'U'¶
- USAGE = 'G'¶
Flags¶
- class firebird.lib.schema.ShadowFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntFlag
Shadow file flags.
- _generate_next_value_(start, count, last_values)¶
Generate the next value when not given.
name: the name of the member start: the initial start value or None count: the number of existing members last_values: the last value assigned or None
- CONDITIONAL = 16¶
- INACTIVE = 2¶
- MANUAL = 4¶
- class firebird.lib.schema.DMLTrigger(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntFlag
DML trigger type codes.
- _generate_next_value_(start, count, last_values)¶
Generate the next value when not given.
name: the name of the member start: the initial start value or None count: the number of existing members last_values: the last value assigned or None
- DELETE = 4¶
- INSERT = 1¶
- UPDATE = 2¶
- class firebird.lib.schema.CollationFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntFlag
Collation attribute flags.
- _generate_next_value_(start, count, last_values)¶
Generate the next value when not given.
name: the name of the member start: the initial start value or None count: the number of existing members last_values: the last value assigned or None
- ACCENT_INSENSITIVE = 4¶
- CASE_INSENSITIVE = 2¶
- NONE = 0¶
- PAD_SPACE = 1¶
Functions¶
Classes¶
- class firebird.lib.schema.Visitor[source]¶
Bases:
object
Base class for Visitor Pattern visitors.
Descendants may implement methods to handle individual object types that follow naming pattern
visit_[class_name]
. Callsdefault_action()
if appropriate special method is not defined.Important
This implementation uses Python Method Resolution Order (__mro__) to find special handling method, so special method for given class is used also for its decendants.
Example:
class Node(object): pass class A(Node): pass class B(Node): pass class C(A,B): pass class MyVisitor(object): def default_action(self, obj): print('default_action ', obj.__class__.__name__) def visit_b(self, obj): print('visit_b ', obj.__class__.__name__) a = A() b = B() c = C() visitor = MyVisitor() visitor.visit(a) visitor.visit(b) visitor.visit(c)
Will create output:
default_action A visit_b B visit_b C
- class firebird.lib.schema.Schema[source]¶
Bases:
Visitable
This class represents database schema.
- bind(connection: Connection) Schema [source]¶
Bind this instance to specified connection`.
- Parameters:
connection (Connection) –
Connection
instance.- Return type:
- close() None [source]¶
Drops link to
Connection
.- Raises:
firebird.base.types.Error – When Schema is owned by Connection instance.
- Return type:
None
- get_charset_by_id(charset_id: int) CharacterSet [source]¶
- Parameters:
charset_id (int) – CharacterSet ID.
- Returns:
CharacterSet
with specified ID orNone
.- Return type:
- get_item(name: str, itype: ObjectType, subname: str = None) SchemaItem [source]¶
Return database object by type and name.
- Parameters:
name (str)
itype (ObjectType)
subname (str)
- Return type:
- get_metadata_ddl(*, sections=[Section.COLLATIONS, Section.CHARACTER_SETS, Section.UDFS, Section.GENERATORS, Section.EXCEPTIONS, Section.DOMAINS, Section.PACKAGE_DEFS, Section.FUNCTION_DEFS, Section.PROCEDURE_DEFS, Section.TABLES, Section.PRIMARY_KEYS, Section.UNIQUE_CONSTRAINTS, Section.CHECK_CONSTRAINTS, Section.FOREIGN_CONSTRAINTS, Section.INDICES, Section.VIEWS, Section.PACKAGE_BODIES, Section.PROCEDURE_BODIES, Section.FUNCTION_BODIES, Section.TRIGGERS, Section.GRANTS, Section.ROLES, Section.COMMENTS, Section.SHADOWS, Section.SET_GENERATORS]) List[str] [source]¶
Return list of DDL SQL commands for creation of specified categories of database objects.
- Keyword Arguments:
sections (
list
) – List of section identifiers.- Returns:
List with SQL commands.
- Return type:
Sections are created in the order of occurence in list. Uses
SCRIPT_DEFAULT_ORDER
list when sections are not specified.
- get_privileges_of(user: str | UserInfo | Table | View | Procedure | Trigger | Role, user_type: ObjectType = None) DataList[Privilege] [source]¶
Get list of all privileges granted to user/database object.
- Parameters:
- Keyword Arguments:
user_type – Required if
user
is provided as string name.- Raises:
ValueError – When
user
is string name anduser_type
is not provided.- Return type:
- reload(data: Category | List[Category] = None) None [source]¶
Commits query transaction and drops all or specified categories of cached metadata objects, so they’re reloaded from database on next reference.
- Parameters:
data (Category | List[Category]) –
None
, metadata category or list of categories.- Raises:
firebird.base.types.Error – For undefined metadata category.
- Return type:
None
- property all_functions: DataList[Function]¶
List of all (system + user) functions defined in database.
- property backup_history: DataList[BackupHistory]¶
List of all nbackup hisotry records.
- property character_sets: DataList[CharacterSet]¶
List of all character sets in database.
- property constraints: DataList[Constraint]¶
List of all constraints in database.
- property default_character_set: CharacterSet¶
Default
CharacterSet
for database.
- property dependencies: DataList[Dependency]¶
List of all dependencies in database.
- property exceptions: DataList[DatabaseException]¶
List of all exceptions in database.
- property files: DataList[DatabaseFile]¶
List of all extension files defined for database.
- mechanism_types = {}¶
Mechanism Types (key = numID, value = type_name)
- param_type_from: Dict[int, str] = {0: 'DATATYPE', 1: 'DOMAIN', 2: 'TYPE OF DOMAIN', 3: 'TYPE OF COLUMN'}¶
Datatype declaration methods for procedure parameters (key = numID, value = name)
- parameter_mechanism_types: Dict[int, str] = {}¶
Parameter Mechanism Types (key = numID, value = type_name)
- property security_class: str¶
Can refer to the security class applied as databasewide access control limits.
- transaction_state_types: Dict[int, str] = {}¶
Transaction State Types (key = numID, value = type_name)
- class firebird.lib.schema.SchemaItem(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
Visitable
Base class for all database schema objects.
- get_dependencies() DataList[Dependency] [source]¶
Returns list of all database objects that this object depend on.
- Return type:
- get_dependents() DataList[Dependency] [source]¶
Returns list of all database objects that depend on this one.
- Return type:
- get_sql_for(action: str, **params: Dict) str [source]¶
Returns SQL command for specified action on metadata object.
Supported actions are defined by
actions
list.- Raises:
ValueError – For unsupported action or wrong parameters passed.
- Parameters:
- Return type:
- class firebird.lib.schema.Collation(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents collation.
- Supported SQL actions:
User collation:
create
,drop
,comment
System collation:
comment
- is_based_on_external() bool [source]¶
Returns True if collation is based on external collation definition.
- Return type:
- property attributes: CollationFlag¶
Collation attributes.
- property character_set: CharacterSet¶
Character set object associated with collation.
- class firebird.lib.schema.CharacterSet(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents character set.
- Supported SQL actions:
alter
(collation=Collation instance or collation name),comment
- class firebird.lib.schema.DatabaseException(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents database exception.
- Supported SQL actions:
User exception:
create
,recreate
,alter
(message=string),create_or_alter
,drop
,comment
System exception:
comment
- class firebird.lib.schema.Sequence(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents database generator/sequence.
- Supported SQL actions:
User sequence:
create
(value=number, increment=number),alter
(value=number, increment=number),drop
,comment
System sequence:
comment
- class firebird.lib.schema.TableColumn(schema: Schema, table: Table, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents table column.
- Supported SQL actions:
User column:
drop
,comment
,alter
(name=string, datatype=string_SQLTypeDef, position=number, expression=computed_by_expr, restart=None_or_init_value)System column:
comment
- get_dependencies() DataList[Dependency] [source]¶
Return list of database objects that this object depend on.
- Return type:
- get_dependents() DataList[Dependency] [source]¶
Return list of all database objects that depend on this one.
- Return type:
- class firebird.lib.schema.Index(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents database index.
- Supported SQL actions:
User index:
create
,activate
,deactivate
,recompute
,drop
,comment
System index:
activate
,recompute
,comment
- _get_recompute_sql(**params) str [source]¶
Returns SQL command to recompute index statistics.
- Return type:
- property constraint: Constraint | None¶
Constraint
instance that uses this index or None.
- property segments: DataList[TableColumn]¶
List of index segments (table columns).
- class firebird.lib.schema.ViewColumn(schema: Schema, view: View, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents view column.
- Supported SQL actions:
comment
- get_dependencies() DataList[Dependency] [source]¶
Return list of database objects that this object depend on.
- Return type:
- get_dependents() DataList[Dependency] [source]¶
Return list of all database objects that depend on this one.
- Return type:
- property base_field: TableColumn | ViewColumn | ProcedureParameter¶
The source column from the base relation. Result could be either
TableColumn
,ViewColumn
orProcedureParameter
instance or None.
- class firebird.lib.schema.Domain(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents SQl Domain.
- Supported SQL actions:
User domain:
create
,drop
,comment
,alter
(name=string, default=string_definition_or_None, check=string_definition_or_None, datatype=string_SQLTypeDef)System domain:
comment
- property character_set: CharacterSet¶
CharacterSet object for a character or text BLOB column, or None.
- property dimensions: List[Tuple[int, int]]¶
List of dimension definition pairs if column is an array type. Always empty for non-array columns.
- property external_length: int¶
Length of field as it is in an external table. Always 0 for regular tables.
- class firebird.lib.schema.Dependency(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Maps dependency between database objects.
- Supported SQL actions:
none
- get_dependencies() DataList [source]¶
Returns empty list because Dependency object never has dependencies.
- Return type:
- get_dependents() DataList [source]¶
Returns empty list because Dependency object never has dependents.
- Return type:
- is_sys_object() bool [source]¶
Returns True as dependency entries are considered as system objects.
- Return type:
- property depended_on: SchemaItem¶
Database object on which dependent depends.
- property depended_on_type: ObjectType¶
Type of db object on which dependent depends.
- property dependent: SchemaItem¶
Dependent database object.
- property dependent_type: ObjectType¶
Dependent database object type.
- class firebird.lib.schema.Constraint(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents table or column constraint.
- Supported SQL actions:
Constraint on user table except NOT NULL constraint:
create
,drop
Constraint on system table:
none
- property column_name: str¶
For a NOT NULL constraint, this is the name of the column to which the constraint applies.
- property constraint_type: ConstraintType¶
Constraint type -> primary key/unique/foreign key/check/not null.
- property delete_rule: str¶
For a FOREIGN KEY constraint, this is the action applicable to when primary key is deleted.
- property index: Index¶
Index
instance that enforces the constraint.None
if constraint is not primary key/unique or foreign key.
- property partner_constraint: Constraint¶
For a FOREIGN KEY constraint, this is the unique or primary key
Constraint
referred.
- class firebird.lib.schema.Table(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents Table in database.
- Supported SQL actions:
User table:
create
(no_pk=bool, no_unique=bool),recreate
(no_pk=bool, no_unique=bool),drop
,comment
,insert (update=bool, returning=list[str], matching=list[str])
System table:
comment
- property columns: DataList[TableColumn]¶
List of columns defined for table.
- property constraints: DataList[Constraint]¶
List of constraints defined for table.
- property foreign_keys: DataList[Constraint]¶
List of FOREIGN KEY constraints for this table.
- property primary_key: Constraint | None¶
PRIMARY KEY constraint for this table or None.
- property table_type: RelationType¶
Table type.
- class firebird.lib.schema.View(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents database View.
- Supported SQL actions:
User views:
create
,recreate
,alter
(columns=string_or_list, query=string,check=bool),create_or_alter
,drop
,comment
System views:
comment
- property columns: DataList[ViewColumn]¶
List of columns defined for view.
- class firebird.lib.schema.Trigger(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents trigger.
- Supported SQL actions:
User trigger:
create
(inactive=bool),recreate
,create_or_alter
,drop
,comment
,alter
(fire_on=string, active=bool,sequence=int, declare=string_or_list, code=string_or_list)System trigger:
comment
- get_type_as_string() str [source]¶
Return string with action and operation specification.
- Return type:
- property action: DMLTrigger | DBTrigger | DDLTrigger¶
Trigger action type.
- property relation: Table | View | None¶
Table
orView
that the trigger is for, or None for database triggers.
- property time: TriggerTime¶
Trigger time (BEFORE/AFTER event).
- property trigger_type: TriggerType¶
Trigger type.
- class firebird.lib.schema.ProcedureParameter(schema: Schema, proc: Procedure, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents procedure parameter.
- Supported SQL actions:
comment
- _get_comment_sql(**params) str [source]¶
Returns SQL command to COMMENT procedure parameter.
- Return type:
- is_packaged() bool [source]¶
Returns True if procedure parameter is defined in package.
- Return type:
- property column: TableColumn¶
TableColumn
for this parameter.
- property parameter_type: ParameterType¶
Parameter type (INPUT/OUTPUT).
- class firebird.lib.schema.Procedure(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents stored procedure.
- Supported SQL actions:
User procedure:
create
(no_code=bool),recreate
no_code=bool),create_or_alter
(no_code=bool),drop
,comment
alter
(input=string_or_list, output=string_or_list, declare=string_or_list, code=string_or_list)System procedure:
comment
- get_param(name: str) ProcedureParameter [source]¶
Returns
ProcedureParameter
with specified name or None.- Parameters:
name (str)
- Return type:
- property input_params: DataList[ProcedureParameter]¶
List of input parameters.
- property output_params: DataList[ProcedureParameter]¶
List of output parameters.
- property proc_type: ProcedureType¶
Procedure type.
- class firebird.lib.schema.Role(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents user role.
- Supported SQL actions:
User role:
create
,drop
,comment
System role:
comment
- class firebird.lib.schema.FunctionArgument(schema: Schema, function: Function, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represets UDF argument.
- Supported SQL actions:
none
- is_by_descriptor(any_=False) bool [source]¶
Returns True if argument is passed by descriptor.
- Parameters:
any – If True, method returns True if
any_
kind of descriptor is used (including BLOB and ARRAY descriptors).- Return type:
- is_returning() bool [source]¶
Returns True if argument represents return value for function.
- Return type:
- is_with_null() bool [source]¶
Returns True if argument is passed by reference with NULL support.
- Return type:
- property character_set: CharacterSet¶
CharacterSet
for a character/text BLOB argument, or None.
- property column: TableColumn¶
TableColumn
for this parameter.
- property precision: int¶
Indicates the number of digits of precision available to the data type of the argument.
- property sub_type: FieldSubType¶
BLOB subtype.
- class firebird.lib.schema.Function(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents user defined function.
- Supported SQL actions:
External UDF:
declare
,drop
,comment
PSQL UDF (not declared in package):
create
(no_code=bool),recreate
(no_code=bool),create_or_alter
(no_code=bool),drop
,alter
(arguments=string_or_list, returns=string, declare=string_or_list, code=string_or_list)System UDF:
none
- has_return_argument() bool [source]¶
Returns True if function returns a value in input argument.
- Return type:
- is_external() bool [source]¶
Returns True if function is external UDF, False for PSQL functions.
- Return type:
- property arguments: DataList[FunctionArgument]¶
List of function arguments.
- property returns: FunctionArgument¶
Returning
FunctionArgument
or None.
- class firebird.lib.schema.DatabaseFile(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents database extension file.
- Supported SQL actions:
create
- class firebird.lib.schema.Shadow(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents database shadow.
- Supported SQL actions:
create
,drop
(preserve=bool)
- property files: DataList[DatabaseFile]¶
List of shadow files.
- property flags: ShadowFlag¶
Shadow flags.
- class firebird.lib.schema.Privilege(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents priviledge to database object.
- Supported SQL actions:
grant
(grantors),revoke
(grantors, grant_option)
- property grant_option: GrantOption¶
Grant option.
- property privilege: PrivilegeCode¶
Privilege code.
- property subject: Role | Table | View | Procedure¶
Priviledge subject. Either
Role
,Table
,View
orProcedure
instance.
- property subject_type: ObjectType¶
Subject type.
- property user: UserInfo | Role | Procedure | Trigger | View¶
Grantee. Either
UserInfo
,Role
,Procedure
,Trigger
orView
object.
- property user_type: ObjectType¶
User type.
- class firebird.lib.schema.Package(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents PSQL package.
- Supported SQL actions:
create
(body=bool),recreate
(body=bool),create_or_alter
(body=bool),alter
(header=string_or_list),drop
(body=bool)
- class firebird.lib.schema.BackupHistory(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents entry of history for backups performed using the nBackup utility.
- Supported SQL actions:
- class firebird.lib.schema.Filter(schema: Schema, attributes: Dict[str, Any])[source]¶
Bases:
SchemaItem
Represents userdefined BLOB filter.
- Supported SQL actions:
BLOB filter:
declare
,drop
,comment
System UDF:
none