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)[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)[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)[source]

Bases: IntEnum

Dependent type codes.

BLOB_FILTER = 16
CHARACTER_SET = 11
CHECK = 4
COLLATION = 17
COLUMN = 9
DOMAIN = 3
EXCEPTION = 7
GENERATOR = 14
INDEX = 10
INDEX_EXPR = 6
PACKAGE = 18
PACKAGE_BODY = 19
PROCEDURE = 5
ROLE = 13
TABLE = 0
TRIGGER = 2
UDF = 15
USER = 8
USER_GROUP = 12
VIEW = 1
class firebird.lib.schema.IndexType(value)[source]

Bases: Enum

Index ordering.

ASCENDING = 'ASCENDING'
DESCENDING = 'DESCENDING'
class firebird.lib.schema.Mechanism(value)[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)[source]

Bases: IntEnum

Transaction state codes.

COMMITTED = 2
LIMBO = 1
ROLLED_BACK = 3
class firebird.lib.schema.SystemFlag(value)[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)[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)[source]

Bases: IntEnum

Procedure type codes.

EXECUTABLE = 2
LEGACY = 0
SELECTABLE = 1
class firebird.lib.schema.ParameterMechanism(value)[source]

Bases: IntEnum

Parameter mechanism type codes.

NORMAL = 0
TYPE_OF = 1
class firebird.lib.schema.TypeFrom(value)[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)[source]

Bases: IntEnum

Parameter type codes.

INPUT = 0
OUTPUT = 1
class firebird.lib.schema.IdentityType(value)[source]

Bases: IntEnum

Identity type codes.

ALWAYS = 0
BY_DEFAULT = 1
class firebird.lib.schema.GrantOption(value)[source]

Bases: IntEnum

Grant option codes.

ADMIN_OPTION = 2
GRANT_OPTION = 1
NONE = 0
class firebird.lib.schema.PageType(value)[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)[source]

Bases: IntEnum

Map to type codes.

ROLE = 1
USER = 0
class firebird.lib.schema.TriggerType(value)[source]

Bases: IntEnum

Trigger type codes.

DB = 8192
DDL = 16384
DML = 0
class firebird.lib.schema.DDLTrigger(value)[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)[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)[source]

Bases: IntEnum

Trigger action time codes.

AFTER = 1
BEFORE = 0
class firebird.lib.schema.ConstraintType(value)[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)[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)[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)[source]

Bases: IntEnum

Privacy flag codes.

PRIVATE = 1
PUBLIC = 0
class firebird.lib.schema.Legacy(value)[source]

Bases: IntEnum

Legacy flag codes.

LEGACY_STYLE = 1
NEW_STYLE = 0
class firebird.lib.schema.PrivilegeCode(value)[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)[source]

Bases: IntFlag

Shadow file flags.

CONDITIONAL = 16
INACTIVE = 2
MANUAL = 4
class firebird.lib.schema.DMLTrigger(value)[source]

Bases: IntFlag

DML trigger type codes.

DELETE = 4
INSERT = 1
UPDATE = 2
class firebird.lib.schema.CollationFlag(value)[source]

Bases: IntFlag

Collation attribute flags.

ACCENT_INSENSITIVE = 4
CASE_INSENSITIVE = 2
NONE = 0
PAD_SPACE = 1

Functions

firebird.lib.schema.get_grants(privileges: List[Privilege], grantors: Optional[List[str]] = None) List[str][source]

Get list of minimal set of SQL GRANT statamenets necessary to grant specified privileges.

Parameters
Keyword Arguments

grantors – List of standard grantor names. Generates GRANTED BY clause for privileges granted by user that’s not in list.

Return type

List[str]

Classes

class firebird.lib.schema.Visitable[source]

Bases: object

Base class for Visitor Pattern support.

accept(visitor: Visitor) None[source]

Visitor Pattern support.

Calls visit(self) on parameter object.

Parameters

visitor (Visitor) – Visitor object of Visitor Pattern.

Return type

None

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]. Calls default_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
default_action(obj: Visitable) None[source]

Default handler for visited objects.

Parameters

obj (Visitable) – Object to be handled.

Return type

None

Note

Default implementation does nothing!

visit(obj: Visitable) Any[source]

Dispatch to method that handles obj.

Parameters

obj (Visitable) – Object to be handled by visitor.

Return type

Any

First traverses the obj.__mro__ to try find method with name following visit_ pattern and calls it with obj. Otherwise it calls default_action().

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

Schema

clear() None[source]

Drop all cached metadata objects.

Return type

None

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 or None.

Return type

CharacterSet

get_collation_by_id(charset_id: int, collation_id: int) Collation[source]

Get Collation by ID.

Parameters
  • charset_id (int) – Character set ID.

  • collation_id (int) – Collation ID.

Returns

Collation with specified ID or None.

Return type

Collation

get_item(name: str, itype: ObjectType, subname: Optional[str] = None) SchemaItem[source]

Return database object by type and name.

Parameters
Return type

SchemaItem

get_metadata_ddl(*, sections=[<Section.COLLATIONS: 1>, <Section.CHARACTER_SETS: 2>, <Section.UDFS: 3>, <Section.GENERATORS: 4>, <Section.EXCEPTIONS: 5>, <Section.DOMAINS: 6>, <Section.PACKAGE_DEFS: 7>, <Section.FUNCTION_DEFS: 8>, <Section.PROCEDURE_DEFS: 9>, <Section.TABLES: 10>, <Section.PRIMARY_KEYS: 11>, <Section.UNIQUE_CONSTRAINTS: 12>, <Section.CHECK_CONSTRAINTS: 13>, <Section.FOREIGN_CONSTRAINTS: 14>, <Section.INDICES: 15>, <Section.VIEWS: 16>, <Section.PACKAGE_BODIES: 17>, <Section.PROCEDURE_BODIES: 18>, <Section.FUNCTION_BODIES: 19>, <Section.TRIGGERS: 20>, <Section.GRANTS: 22>, <Section.ROLES: 21>, <Section.COMMENTS: 23>, <Section.SHADOWS: 24>, <Section.SET_GENERATORS: 25>]) 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

List[str]

Sections are created in the order of occurence in list. Uses SCRIPT_DEFAULT_ORDER list when sections are not specified.

get_privileges_of(user: Union[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_typeRequired if user is provided as string name.

Raises

ValueError – When user is string name and user_type is not provided.

Return type

DataList[Privilege]

is_keyword(ident: str) bool[source]

Return True if ident is a Firebird keyword.

Parameters

ident (str) –

Return type

bool

is_multifile() bool[source]

Returns True if database has multiple files.

Return type

bool

reload(data: Optional[Union[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 (Optional[Union[Category, List[Category]]]) – None, metadata category or list of categories.

Raises

firebird.base.types.Error – For undefined metadata category.

Return type

None

property all_domains: DataList[Domain]

List of all (system + user) domains in database.

property all_functions: DataList[Function]

List of all (system + user) functions defined in database.

property all_generators: DataList[Sequence]

List of all (system + user) generators in database.

property all_indices: DataList[Index]

List of all (system + user) indices in database.

property all_procedures: DataList[Procedure]

List of all (system + user) procedures in database.

property all_tables: DataList[Table]

List of all (system + user) tables in database.

property all_triggers: DataList[Trigger]

List of all (system + user) triggers in database.

property all_views: DataList[View]

List of all system (system + user) in database.

property backup_history: DataList[BackupHistory]

List of all nbackup hisotry records.

character_set_names: Dict[int, str] = {}

Character set names (key = numID, value = charset_name)

property character_sets: DataList[CharacterSet]

List of all character sets in database.

property closed: bool

True if schema is not bound to database connection.

property collations: DataList[Collation]

List of all collations 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 description: Optional[str]

Database description or None if it doesn’t have a description.

deterministic_flags: Dict[int, str] = {}

Determinism flags (numID, value = flag_name)

property domains: DataList[Domain]

List of all user domains in database.

property exceptions: DataList[DatabaseException]

List of all exceptions in database.

field_subtypes: Dict[int, str] = {}

Field sub types (key = numID, value = type_name)

field_types: Dict[int, str] = {}

Field types (key = numID, value = type_name)

property files: DataList[DatabaseFile]

List of all extension files defined for database.

property filters: DataList[Filter]

List of all user-defined BLOB filters.

function_types: Dict[int, str] = {}

Function types (key = numID, value = type_name)

property functions: DataList[Function]

List of all user functions defined in database.

property generators: DataList[Sequence]

List of all user generators in database.

grant_options: Dict[int, str] = {}

Grant option (key = numID, value = option_name)

identity_type: Dict[int, str] = {}

Identity type (key = numID, value = type_name)

index_activity_flags: Dict[int, str] = {}

Index activity status (key = numID, value = flag_name)

index_unique_flags: Dict[int, str] = {}

Index uniqueness (key = numID, value = flag_name)

property indices: DataList[Index]

List of all user indices in database.

legacy_flags: Dict[int, str] = {}

Legacy flags (numID, value = flag_name)

property linger: Optional[int]

Database linger value.

mechanism_types = {}

Mechanism Types (key = numID, value = type_name)

object_type_codes: Dict[str, int] = {}

Object type codes (key = type_name, value = numID)

object_types: Dict[int, str] = {}

Object types (key = numID, value = type_name)

opt_always_quote: bool = False

Configuration option - Always quote db object names on output

opt_generator_keyword: str = 'SEQUENCE'

Configuration option - Keyword for generator/sequence

property owner_name: str

Database owner name.

property packages: DataList[Package]

List of all packages defined for database.

page_types: Dict[int, str] = {}

Page type (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)

parameter_types: Dict[int, str] = {}

Parameter Types (key = numID, value = type_name)

privacy_flags: Dict[int, str] = {}

Privacy flags (numID, value = flag_name)

property privileges: DataList[Privilege]

List of all privileges defined for database.

procedure_types: Dict[int, str] = {}

Procedure Types (key = numID, value = type_name)

property procedures: DataList[Procedure]

List of all user procedures in database.

relation_types: Dict[int, str] = {}

Relation Types (key = numID, value = type_name)

property roles: DataList[Role]

List of all roles in database.

property security_class: str

Can refer to the security class applied as databasewide access control limits.

property shadows: DataList[Shadow]

List of all shadows defined for database.

property sys_domains: DataList[Domain]

List of all system domains in database.

property sys_functions: DataList[Function]

List of all system functions defined in database.

property sys_generators: DataList[Sequence]

List of all system generators in database.

property sys_indices: DataList[Index]

List of all system indices in database.

property sys_procedures: DataList[Procedure]

List of all system procedures in database.

property sys_tables: DataList[Table]

List of all system tables in database.

property sys_triggers: DataList[Trigger]

List of all system triggers in database.

property sys_views: DataList[View]

List of all system views in database.

system_flag_types: Dict[int, str] = {}

System Flag Types (key = numID, value = type_name)

property tables: DataList[Table]

List of all user tables in database.

transaction_state_types: Dict[int, str] = {}

Transaction State Types (key = numID, value = type_name)

trigger_activity_flags: Dict[int, str] = {}

Trigger activity status (key = numID, value = flag_name)

trigger_types: Dict[int, str] = {}

Trigger Types (key = numID, value = type_name)

property triggers: DataList[Trigger]

List of all user triggers in database.

property views: DataList[View]

List of all user views in database.

class firebird.lib.schema.SchemaItem(schema: Schema, attributes: Dict[str, Any])[source]

Bases: Visitable

Base class for all database schema objects.

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

get_dependencies() DataList[Dependency][source]

Returns list of all database objects that this object depend on.

Return type

DataList[Dependency]

get_dependents() DataList[Dependency][source]

Returns list of all database objects that depend on this one.

Return type

DataList[Dependency]

get_quoted_name() str[source]

Returns quoted (if necessary) name.

Return type

str

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
  • action (str) –

  • params (Dict) –

Return type

str

is_sys_object() bool[source]

Returns True if this database object is system object.

Return type

bool

property actions: List[str]

List of supported SQL operations on metadata object instance.

property description: str

Database object description or None if object doesn’t have a description.

property name: str

Database object name or None if object doesn’t have a name.

schema: Schema = None

Weak reference to parent Schema instance.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT collation.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE collation.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP collation.

Return type

str

is_based_on_external() bool[source]

Returns True if collation is based on external collation definition.

Return type

bool

property attributes: CollationFlag

Collation attributes.

property base_collation: Collation

Base Collation object that’s extended by this one, or None.

property character_set: CharacterSet

Character set object associated with collation.

property function_name: str

Not currently used.

property id: int

Collation ID.

property owner_name: str

Creator’s user name.

property security_class: str

Security class name or None.

property specific_attributes: str

Collation specific attributes.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER charset.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT charset.

Return type

str

get_collation_by_id(id_: int) Optional[Collation][source]

Return Collation object with specified id_ that belongs to this character set.

Parameters

id_ (int) –

Return type

Optional[Collation]

property bytes_per_character: int

Size of characters in bytes.

property collations: DataList[Collation]

List of collations associated with character set.

property default_collate: Collation

Collate object of default collate.

property id: int

Character set ID.

property owner_name: str

Creator user name.

property security_class: str

Security class name or None.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER exception.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT exception.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE exception.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP exception.

Return type

str

property id: int

System-assigned unique exception number.

property message: str

Custom message text.

property owner_name: str

Creator’s user name.

property security_class: str

Security class name or None.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER sequence.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT sequence.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE sequence.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP sequence.

Return type

str

is_identity() bool[source]

Returns True for system generators created for IDENTITY columns.

Return type

bool

property id: int

Internal ID number of the sequence.

property increment: int

Sequence increment.

property inital_value: int

Initial sequence value.

property owner_name: str

Creator’s user name.

property security_class: str

Security class name or None.

property value: int

Current sequence value.

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

Parameters
  • schema (Schema) –

  • table (Table) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER table column.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT table column.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP table column.

Return type

str

get_computedby() str[source]

Returns extression for column computation or None.

Return type

str

get_dependencies() DataList[Dependency][source]

Return list of database objects that this object depend on.

Return type

DataList[Dependency]

get_dependents() DataList[Dependency][source]

Return list of all database objects that depend on this one.

Return type

DataList[Dependency]

has_default() bool[source]

Returns True if column has default value.

Return type

bool

is_computed() bool[source]

Returns True if column is computed.

Return type

bool

is_domain_based() bool[source]

Returns True if column is based on user domain.

Return type

bool

is_identity() bool[source]

Returns True for identity type column.

Return type

bool

is_nullable() bool[source]

Returns True if column can accept NULL values.

Return type

bool

is_writable() bool[source]

Returns True if column is writable (i.e. it’s not computed etc.).

Return type

bool

property collation: Collation

Collation object or None.

property datatype: str

Comlete SQL datatype definition.

property default: str

Default value for column or None.

property domain: Domain

Domain object this column is based on.

property generator: Sequence

Identity Sequence.

property id: int

Internam number ID for the column.

property identity_type: int

Identity type, None for normal columns.

property position: int

Column’s sequence number in row.

property privileges: DataList[Privilege]

List of privileges granted to column.

property security_class: str

Security class name or None.

property table: Table

The Table object this column belongs to.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_activate_sql(**params) str[source]

Returns SQL command to ACTIVATE index.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT index.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE index.

Return type

str

_get_deactivate_sql(**params) str[source]

Returns SQL command to DEACTIVATE index.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP index.

Return type

str

_get_recompute_sql(**params) str[source]

Returns SQL command to recompute index statistics.

Return type

str

is_enforcer() bool[source]

Returns True if index is used to enforce a constraint.

Return type

bool

is_expression() bool[source]

Returns True if index is expression index.

Return type

bool

is_inactive() bool[source]

Returns True if index is INACTIVE.

Return type

bool

is_sys_object() bool[source]

Returns True if this database object is system object.

Return type

bool

is_unique() bool[source]

Returns True if index is UNIQUE.

Return type

bool

property constraint: Constraint

Constraint instance that uses this index or None.

property expression: str

Source of an expression or None.

property id: int

Internal number ID of the index.

property index_type: IndexType

Index type (ASCENDING or DESCENDING).

property partner_index: Index

Associated unique/primary key Index instance, or None.

property segment_names: List[str]

List of index segment names.

property segment_statistics: List[float]

List of index segment statistics.

property segments: DataList[TableColumn]

List of index segments (table columns).

property statistics: float

Latest selectivity of the index.

property table: Table

The Table instance the index applies to.

class firebird.lib.schema.ViewColumn(schema: Schema, view: View, attributes: Dict[str, Any])[source]

Bases: SchemaItem

Represents view column.

Supported SQL actions:

comment

Parameters
  • schema (Schema) –

  • view (View) –

  • attributes (Dict[str, Any]) –

_get_comment_sql(**params) str[source]

Returns SQL command to CREATE view column.

Return type

str

get_dependencies() DataList[Dependency][source]

Return list of database objects that this object depend on.

Return type

DataList[Dependency]

get_dependents() DataList[Dependency][source]

Return list of all database objects that depend on this one.

Return type

DataList[Dependency]

is_nullable() bool[source]

Returns True if column is NULLABLE.

Return type

bool

is_writable() bool[source]

Returns True if column is writable.

Return type

bool

property base_field: Union[TableColumn, ViewColumn, ProcedureParameter]

The source column from the base relation. Result could be either TableColumn, ViewColumn or ProcedureParameter instance or None.

property collation: Collation

Collation object or None.

property datatype: str

Complete SQL datatype definition.

property domain: Domain

Domain object this column is based on.

property position: int

Column’s sequence number in row.

property privileges: DataList[Privilege]

List of privileges granted to column.

property security_class: str

Security class name or None.

property view: View

View object this column belongs to.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER domain.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT dimain.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE domain.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP domain.

Return type

str

has_default() bool[source]

Returns True if domain has default value.

Return type

bool

is_array() bool[source]

Returns True if domain defines an array.

Return type

bool

is_computed() bool[source]

Returns True if domain is computed.

Return type

bool

is_nullable() bool[source]

Returns True if domain is not defined with NOT NULL.

Return type

bool

is_sys_object() bool[source]

Return True if this database object is system object.

Return type

bool

is_validated() bool[source]

Returns True if domain has validation constraint.

Return type

bool

property character_length: int

Length of CHAR and VARCHAR column, in characters (not bytes).

property character_set: CharacterSet

CharacterSet object for a character or text BLOB column, or None.

property collation: Collation

Collation object for a character column or None.

property datatype: str

Comlete SQL datatype definition.

property default: str

Expression that defines the default value 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 expression: str

Expression that defines the COMPUTED BY column or None.

property external_length: int

Length of field as it is in an external table. Always 0 for regular tables.

property external_scale: int

Scale factor of an integer field as it is in an external table.

property external_type: FieldType

Data type of the field as it is in an external table.

property field_type: FieldType

Number code of the data type defined for the column.

property length: int

Length of the column in bytes.

property owner_name: str

Creator’s user name.

property precision: int

Indicates the number of digits of precision available to the data type of the column.

property scale: int

Negative number representing the scale of NUMBER and DECIMAL column.

property security_class: str

Security class name or None.

property segment_length: int

For BLOB columns, a suggested length for BLOB buffers.

property sub_type: int

Field sub-type.

property validation: str

CHECK constraint for the domain or None.

class firebird.lib.schema.Dependency(schema: Schema, attributes: Dict[str, Any])[source]

Bases: SchemaItem

Maps dependency between database objects.

Supported SQL actions:

none

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

get_dependencies() DataList[source]

Returns empty list because Dependency object never has dependencies.

Return type

DataList

get_dependents() DataList[source]

Returns empty list because Dependency object never has dependents.

Return type

DataList

is_packaged() bool[source]

Returns True if dependency is defined in package.

Return type

bool

is_sys_object() bool[source]

Returns True as dependency entries are considered as system objects.

Return type

bool

property depended_on: SchemaItem

Database object on which dependent depends.

property depended_on_name: str

Name of db 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_name: str

Dependent database object name.

property dependent_type: ObjectType

Dependent database object type.

property field_name: str

Name of one column in depended on object.

property package: Package

Package instance if dependent depends on object in package or None.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_create_sql(**params) str[source]

Returns SQL command to CREATE constraint.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP constraint.

Return type

str

is_check() bool[source]

Returns True if it’s CHECK constraint.

Return type

bool

is_deferrable() bool[source]

Returns True if it’s DEFERRABLE constraint.

Return type

bool

is_deferred() bool[source]

Returns True if it’s INITIALLY DEFERRED constraint.

Return type

bool

is_fkey() bool[source]

Returns True if it’s FOREIGN KEY constraint.

Return type

bool

is_not_null() bool[source]

Returns True if it’s NOT NULL constraint.

Return type

bool

is_pkey() bool[source]

Returns True if it’s PRIMARY KEY constraint.

Return type

bool

is_sys_object() bool[source]

Returns True if this database object is system object.

Return type

bool

is_unique() bool[source]

Returns True if it’s UNIQUE constraint.

Return type

bool

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 match_option: str

For a FOREIGN KEY constraint only. Current value is FULL in all cases.

property partner_constraint: Constraint

For a FOREIGN KEY constraint, this is the unique or primary key Constraint referred.

property table: Table

Table instance this constraint applies to.

property trigger_names: List[str]

For a CHECK constraint contains trigger names that enforce the constraint.

property triggers: DataList[Trigger]

List of triggers that enforce the CHECK constraint.

property update_rule: str

For a FOREIGN KEY constraint, this is the action applicable to when primary key is updated.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT table.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE table.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP table.

Return type

str

_get_insert_sql(**params) str[source]

Returns SQL command to INSERT data to table.

Return type

str

has_fkey() bool[source]

Returns True if table has any FOREIGN KEY constraint.

Return type

bool

has_pkey() bool[source]

Returns True if table has PRIMARY KEY defined.

Return type

bool

is_external() bool[source]

Returns True if table is external table.

Return type

bool

is_gtt() bool[source]

Returns True if table is GLOBAL TEMPORARY table.

Return type

bool

is_persistent() bool[source]

Returns True if table is persistent one.

Return type

bool

property columns: DataList[TableColumn]

List of columns defined for table.

property constraints: DataList[Constraint]

List of constraints defined for table.

property dbkey_length: int

Length of the RDB$DB_KEY column in bytes.

property default_class: str

Default security class.

property external_file: str

Full path to the external data file, if any.

property flags: int

Internal flags.

property foreign_keys: DataList[Constraint]

List of FOREIGN KEY constraints for this table.

property format: int

Internal format ID for the table.

property id: int

Internal number ID for the table.

property indices: DataList[Index]

List of indices defined for table.

property owner_name: str

User name of table’s creator.

property primary_key: Optional[Constraint]

PRIMARY KEY constraint for this table or None.

property privileges: DataList[Privilege]

List of privileges to table.

property security_class: str

Security class that define access limits to the table.

property table_type: RelationType

Table type.

property triggers: DataList[Trigger]

List of triggers defined for table.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER view.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT view.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE view.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP view.

Return type

str

has_checkoption() bool[source]

Returns True if View has WITH CHECK OPTION defined.

Return type

bool

property columns: DataList[ViewColumn]

List of columns defined for view.

property dbkey_length: int

Length of the RDB$DB_KEY column in bytes.

property default_class: str

Default security class.

property flags: int

Internal flags.

property format: int

Internal format ID for the view.

property id: int

Internal number ID for the view.

property owner_name: str

User name of view’s creator.

property privileges: DataList[Privilege]

List of privileges granted to view.

property security_class: str

Security class that define access limits to the view.

property sql: str

The query specification.

property triggers: DataList[Trigger]

List of triggers 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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER trigger.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT trigger.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE trigger.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP trigger.

Return type

str

get_type_as_string() str[source]

Return string with action and operation specification.

Return type

str

is_after() bool[source]

Returns True if this trigger is set for AFTER action.

Return type

bool

is_before() bool[source]

Returns True if this trigger is set for BEFORE action.

Return type

bool

is_db_trigger() bool[source]

Returns True if this trigger is database trigger.

Return type

bool

is_ddl_trigger() bool[source]

Returns True if this trigger is DDL trigger.

Return type

bool

is_delete() bool[source]

Returns True if this trigger is set for DELETE operation.

Return type

bool

is_insert() bool[source]

Returns True if this trigger is set for INSERT operation.

Return type

bool

is_update() bool[source]

Returns True if this trigger is set for UPDATE operation.

Return type

bool

property action: Union[DMLTrigger, DBTrigger, DDLTrigger]

Trigger action type.

property active: bool

True if this trigger is active.

property engine_name: str

Engine name.

property entrypoint: str

Entrypoint.

property flags: int

Internal flags.

property relation: Optional[Union[Table, View]]

Table or View that the trigger is for, or None for database triggers.

property sequence: int

Sequence (position) of trigger. Zero usually means no sequence defined.

property source: str

PSQL source code.

property time: TriggerTime

Trigger time (BEFORE/AFTER event).

property trigger_type: TriggerType

Trigger type.

property valid_blr: bool

Trigger BLR invalidation flag. Coul be True/False or None.

class firebird.lib.schema.ProcedureParameter(schema: Schema, proc: Procedure, attributes: Dict[str, Any])[source]

Bases: SchemaItem

Represents procedure parameter.

Supported SQL actions:

comment

Parameters
_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT procedure parameter.

Return type

str

get_sql_definition() str[source]

Returns SQL definition for parameter.

Return type

str

has_default() bool[source]

Returns True if parameter has default value.

Return type

bool

is_input() bool[source]

Returns True if parameter is INPUT parameter.

Return type

bool

is_nullable() bool[source]

Returns True if parameter allows NULL.

Return type

bool

is_packaged() bool[source]

Returns True if procedure parameter is defined in package.

Return type

bool

property collation: Collation

Collation for this parameter.

property column: TableColumn

TableColumn for this parameter.

property datatype: str

Comlete SQL datatype definition.

property default: str

Default value.

property domain: Domain

Domain for this parameter.

property mechanism: Mechanism

Parameter mechanism code.

property package: Package

Package this procedure belongs to.

property parameter_type: ParameterType

Parameter type (INPUT/OUTPUT).

property procedure: Procedure

Procedure instance to which this parameter belongs.

property sequence: int

Sequence (position) of parameter.

property type_from: TypeFrom

Source for parameter data type.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER procedure.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT procedure.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE procedure.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP procedure.

Return type

str

get_param(name: str) ProcedureParameter[source]

Returns ProcedureParameter with specified name or None.

Parameters

name (str) –

Return type

ProcedureParameter

has_input() bool[source]

Returns True if procedure has any input parameters.

Return type

bool

has_output() bool[source]

Returns True if procedure has any output parameters.

Return type

bool

is_packaged() bool[source]

Returns True if procedure is defined in package.

Return type

bool

property engine_name: str

Engine name.

property entrypoint: str

Entrypoint.

property id: int

Internal unique ID number.

property input_params: DataList[ProcedureParameter]

List of input parameters.

property output_params: DataList[ProcedureParameter]

List of output parameters.

property owner_name: str

User name of procedure’s creator.

property package: Package

Package this procedure belongs to.

property privacy: Privacy

Privacy flag.

property privileges: DataList[Privilege]

List of privileges granted to procedure.

property proc_type: ProcedureType

Procedure type.

property security_class: str

Security class that define access limits to the procedure.

property source: str

PSQL source code.

property valid_blr: bool

Procedure BLR invalidation flag. Coul be True/False or None.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT role.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE role.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP role.

Return type

str

property owner_name: str

User name of role owner.

property privileges: DataList[Privilege]

List of privileges granted to role.

property security_class: str

Security class name or None.

class firebird.lib.schema.FunctionArgument(schema: Schema, function: Function, attributes: Dict[str, Any])[source]

Bases: SchemaItem

Represets UDF argument.

Supported SQL actions:

none

Parameters
get_sql_definition() str[source]

Returns SQL definition for parameter.

Return type

str

has_default() bool[source]

Returns True if parameter has default value.

Return type

bool

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

bool

is_by_reference() bool[source]

Returns True if argument is passed by reference.

Return type

bool

is_by_value() bool[source]

Returns True if argument is passed by value.

Return type

bool

is_freeit() bool[source]

Returns True if (return) argument is declared as FREE_IT.

Return type

bool

is_nullable() bool[source]

Returns True if parameter allows NULL.

Return type

bool

is_packaged() bool[source]

Returns True if function argument is defined in package.

Return type

bool

is_returning() bool[source]

Returns True if argument represents return value for function.

Return type

bool

is_with_null() bool[source]

Returns True if argument is passed by reference with NULL support.

Return type

bool

property argument_mechanism: Mechanism

Argument mechanism.

property argument_name: str

Argument name.

property character_length: int

Length of CHAR and VARCHAR column, in characters (not bytes).

property character_set: CharacterSet

CharacterSet for a character/text BLOB argument, or None.

property collation: Collation

Collation for this parameter.

property column: TableColumn

TableColumn for this parameter.

property datatype: str

Comlete SQL datatype definition.

property default: str

Default value.

property domain: Domain

Domain for this parameter.

property field_type: FieldType

Number code of the data type defined for the argument.

property function: Function

Function to which this argument belongs.

property length: int

Length of the argument in bytes.

property mechanism: Mechanism

How argument is passed.

property package: Package

Package this function belongs to.

property position: int

Argument position.

property precision: int

Indicates the number of digits of precision available to the data type of the argument.

property scale: int

Negative number representing the scale of NUMBER and DECIMAL argument.

property sub_type: FieldSubType

BLOB subtype.

property type_from: TypeFrom

Source for parameter data type.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER object.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT function.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE function.

Return type

str

_get_declare_sql(**params) str[source]

Returns SQL command to DECLARE function.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP function.

Return type

str

has_arguments() bool[source]

Returns True if function has input arguments.

Return type

bool

has_return() bool[source]

Returns True if function returns a value.

Return type

bool

has_return_argument() bool[source]

Returns True if function returns a value in input argument.

Return type

bool

is_external() bool[source]

Returns True if function is external UDF, False for PSQL functions.

Return type

bool

is_packaged() bool[source]

Returns True if function is defined in package.

Return type

bool

property arguments: DataList[FunctionArgument]

List of function arguments.

property deterministic_flag: int

Deterministic flag.

property engine_mame: str

Engine name.

property entrypoint: str

Entrypoint in module.

property id: int

Function ID.

property legacy_flag: Legacy

Legacy flag.

property module_name: str

Module name.

property owner_name: str

Owner name.

property package: Package

Package this function belongs to.

property private_flag: Privacy

Private flag.

property returns: FunctionArgument

Returning FunctionArgument or None.

property security_class: str

Security class.

property source: str

Function source.

property valid_blr: bool

BLR validity flag.

class firebird.lib.schema.DatabaseFile(schema: Schema, attributes: Dict[str, Any])[source]

Bases: SchemaItem

Represents database extension file.

Supported SQL actions:

create

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

is_sys_object() bool[source]

Always returns True.

Return type

bool

property filename: str

File name.

property length: str

File length in pages.

property sequence: int

File sequence number.

property start: int

File start page number.

class firebird.lib.schema.Shadow(schema: Schema, attributes: Dict[str, Any])[source]

Bases: SchemaItem

Represents database shadow.

Supported SQL actions:

create, drop (preserve=bool)

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_create_sql(**params) str[source]

Returns SQL command to CREATE shadow.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP shadow.

Return type

str

is_conditional() bool[source]

Returns True if it’s CONDITIONAL shadow.

Return type

bool

is_inactive() bool[source]

Returns True if it’s INACTIVE shadow.

Return type

bool

is_manual() bool[source]

Returns True if it’s MANUAL shadow.

Return type

bool

is_sys_object() bool[source]

Always returns False.

Return type

bool

property files: DataList[DatabaseFile]

List of shadow files.

property flags: ShadowFlag

Shadow flags.

property id: int

Shadow ID number.

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)

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_grant_sql(**params) str[source]

Returns SQL command to GRANT privilege.

Return type

str

_get_revoke_sql(**params) str[source]

Returns SQL command to REVOKE privilege.

Return type

str

has_grant() bool[source]

Returns True if privilege comes with GRANT OPTION.

Return type

bool

is_delete() bool[source]

Returns True if this is DELETE privilege.

Return type

bool

is_execute() bool[source]

Returns True if this is EXECUTE privilege.

Return type

bool

is_insert() bool[source]

Returns True if this is INSERT privilege.

Return type

bool

is_membership() bool[source]

Returns True if this is ROLE membership privilege.

Return type

bool

is_reference() bool[source]

Returns True if this is REFERENCE privilege.

Return type

bool

is_select() bool[source]

Returns True if this is SELECT privilege.

Return type

bool

is_sys_object() bool[source]

Always returns True.

Return type

bool

is_update() bool[source]

Returns True if this is UPDATE privilege.

Return type

bool

property field_name: str

Field name.

property grant_option: GrantOption

Grant option.

property grantor: UserInfo

Grantor User object.

property grantor_name: str

Grantor name.

property privilege: PrivilegeCode

Privilege code.

property subject: Union[Role, Table, View, Procedure]

Priviledge subject. Either Role, Table, View or Procedure instance.

property subject_name: str

Subject name.

property subject_type: ObjectType

Subject type.

property user: Union[UserInfo, Role, Procedure, Trigger, View]

Grantee. Either UserInfo, Role, Procedure, Trigger or View object.

property user_name: str

User name.

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)

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_alter_sql(**params) str[source]

Returns SQL command to ALTER package.

Return type

str

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT package.

Return type

str

_get_create_sql(**params) str[source]

Returns SQL command to CREATE package.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP package.

Return type

str

has_valid_body() bool[source]

Returns True if package has valid body.

Return type

bool

property body: str

Package body source.

property functions: DataList[Function]

List of package functions.

property header: str

Package header source.

property owner_name: str

User name of package creator.

property procedures: DataList[Procedure]

List of package procedures.

property security_class: str

Security class name or None.

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:

None

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

is_sys_object() bool[source]

Always returns True.

Return type

bool

property created: datetime

Backup date and time.

property filename: str

Full path and file name of backup file.

property guid: str

Unique identifier.

property id: int

The identifier assigned by the engine.

property level: int

Backup level.

property scn: int

System (scan) number.

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

Parameters
  • schema (Schema) –

  • attributes (Dict[str, Any]) –

_get_comment_sql(**params) str[source]

Returns SQL command to COMMENT filter.

Return type

str

_get_declare_sql(**params) str[source]

Returns SQL command to DECLARE filter.

Return type

str

_get_drop_sql(**params) str[source]

Returns SQL command to DROP filter.

Return type

str

property entrypoint: str

The exported name of the BLOB filter in the filter library.

property input_sub_type: int

The BLOB subtype of the data to be converted by the function.

property module_name: str

The name of the dynamic library or shared object where the code of the BLOB filter is located.

property output_sub_type: int

The BLOB subtype of the converted data.