Interbase Reference

Module globals

interbase.__version__

Current driver version, string.

interbase.apilevel

String constant stating the supported DB API level (2.0).

interbase.threadsafety

Integer constant stating the level of thread safety the interface supports.

Curretly 1 = Threads may share the module, but not connections.

interbase.paramstyle

String constant stating the type of parameter marker formatting expected by the interface.

‘qmark’ = Question mark style, e.g. ‘…WHERE name=?’

interbase.DESCRIPTION_NAME
interbase.DESCRIPTION_TYPE_CODE
interbase.DESCRIPTION_DISPLAY_SIZE
interbase.DESCRIPTION_INTERNAL_SIZE
interbase.DESCRIPTION_PRECISION
interbase.DESCRIPTION_SCALE
interbase.DESCRIPTION_NULL_OK

Helper constants for work with Cursor.description content.

interbase.ISOLATION_LEVEL_READ_COMMITED_LEGACY

TPB for R/W WAIT READ COMMITTED NO RECORD VERSION transaction.

interbase.ISOLATION_LEVEL_READ_COMMITED

TPB for R/W WAIT READ COMMITTED RECORD VERSION transaction.

interbase.ISOLATION_LEVEL_REPEATABLE_READ
interbase.ISOLATION_LEVEL_SNAPSHOT

TPB’s for R/W WAIT SNAPSHOT transaction.

interbase.ISOLATION_LEVEL_SERIALIZABLE
interbase.ISOLATION_LEVEL_SNAPSHOT_TABLE_STABILITY

TPB’s for R/W WAIT SNAPSHOT TABLE STABILITY transaction.

interbase.ISOLATION_LEVEL_READ_COMMITED_RO

TPB for R/O WAIT READ COMMITTED RECORD VERSION transaction.

interbase.MAX_BLOB_SEGMENT_SIZE
interbase.charset_map

Python dictionary that maps InterBase character set names (key) to Python character sets (value).

Exceptions

exception interbase.Warning

Bases: Exception

Exception raised for important warnings like data truncations while inserting, etc.

exception interbase.Error

Bases: Exception

Exception that is the base class of all other error exceptions. You can use this to catch all errors with one single ‘except’ statement. Warnings are not considered errors and thus should not use this class as base.

exception interbase.InterfaceError

Bases: Error

Exception raised for errors that are related to the database interface rather than the database itself.

exception interbase.DatabaseError

Bases: Error

Exception raised for errors that are related to the database.

exception interbase.DataError

Bases: DatabaseError

Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range, etc.

exception interbase.OperationalError

Bases: DatabaseError

Exception raised for errors that are related to the database’s operation and not necessarily under the control of the programmer, e.g. an unexpected disconnect occurs, the data source name is not found, a transaction could not be processed, a memory allocation error occurred during processing, etc.

exception interbase.IntegrityError

Bases: DatabaseError

Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails.

exception interbase.InternalError

Bases: DatabaseError

Exception raised when the database encounters an internal error, e.g. the cursor is not valid anymore, the transaction is out of sync, etc.

exception interbase.ProgrammingError

Bases: DatabaseError

Exception raised for programming errors, e.g. table not found or already exists, syntax error in the SQL statement, wrong number of parameters specified, etc.

exception interbase.NotSupportedError

Bases: DatabaseError

Exception raised in case a method or database API was used which is not supported by the database

exception interbase.TransactionConflict

Bases: DatabaseError

This is the exception inheritance layout:

StandardError
|__Warning
|__Error
   |__InterfaceError
   |__DatabaseError
      |__DataError
      |__OperationalError
      |__IntegrityError
      |__InternalError
      |__ProgrammingError
      |__NotSupportedError

Functions

interbase.connect(dsn='', user=None, password=None, host=None, database=None, sql_dialect=3, role=None, charset=None, buffers=None, force_write=None, no_reserve=None, db_key_scope=None, isolation_level=b'\x03\t\x06\x0f\x11', encrypted_password=None, connection_class=None, ib_library_name=None, sep_password=None, ssl=False, client_pass_phrase_file=None, client_pass_phrase=None, client_cert_file=None, server_public_file=None, server_public_path=None, embedded=False)

Establish a connection to database.

Parameters:
  • dsn – Connection string in format [host[/port]]:database

  • user (string) – User name. If not specified, interbase attempts to use ISC_USER envar.

  • password (string) – User password. If not specified, interbase attempts to use ISC_PASSWORD envar.

  • host (string) – Server host machine specification.

  • database (string) – Database specification (file spec. or alias)

  • sql_dialect – SQL Dialect for connection.

  • role (string) – User role.

  • charset (string) – Character set for connection.

  • buffers (integer) – Page case size override for connection.

  • force_writes (integer) – Forced writes override for connection.

  • no_reserve (integer) – Page space reservation override for connection.

  • db_key_scope (integer) – DBKEY scope override for connection.

  • isolation_level (0, 1, 2 or 3) – Default transaction isolation level for connection (not used).

  • connection_class (subclass of Connection) – Custom connection class

  • ib_library_name (string) – Full path to InterBase client library. See load_api() for details.

  • ssl (bool) – Enable ssl connection to database.

  • encrypted_password (string) – Encrypted password.

  • sep_password (string) – Database system encryption password.

  • server_public_file (string) – server public file

  • client_cert_file (string) – client cert file.

  • client_pass_phrase (string) – Passphrase

  • client_pass_phrase_file (string) – File with pass phrase.

  • server_public_path (string) – Server public file path.

  • embedded (bool) – Use embedded client library.

Returns:

Connection to database.

Return type:

Connection instance.

Raises:

Important

You may specify the database using either dns or database (with optional host), but not both.

Examples:

con = interbase.connect(dsn='host:/path/database.interbase', user='sysdba', password='pass', charset='UTF8')
con = interbase.connect(host='myhost', database='/path/database.interbase', user='sysdba', password='pass', charset='UTF8')
interbase.create_database(sql='', sql_dialect=3, dsn='', user=None, password=None, host=None, database=None, page_size=None, length=None, charset=None, files=None, connection_class=None, ib_library_name=None, ssl=False, client_pass_phrase_file=None, client_pass_phrase=None, client_cert_file=None, server_public_file=None, server_public_path=None, embedded=False)

Creates a new database. Parameters could be specified either by supplied “CREATE DATABASE” statement, or set of database parameters.

Parameters:
  • sql – “CREATE DATABASE” statement.

  • sql_dialect (1 or 3) – SQL Dialect for newly created database.

  • dsn – Connection string in format [host[/port]]:database

  • user (string) – User name. If not specified, interbase attempts to use ISC_USER envar.

  • password (string) – User password. If not specified, interbase attempts to use ISC_PASSWORD envar.

  • host (string) – Server host machine specification.

  • database (string) – Database specification (file spec. or alias)

  • page_size (integer) – Database page size.

  • length (integer) – Database size in pages.

  • charset (string) – Character set for connection.

  • files (string) – Specification of secondary database files.

  • connection_class (subclass of Connection) – Custom connection class

  • ib_library_name (string) – Full path to InterBase client library. See load_api() for details.

  • embedded (bool) – Load embedded version of the driver.

Returns:

Connection to the newly created database.

Return type:

Connection instance.

Raises:

Example:

con = interbase.create_database("create database '/temp/db.interbase' user 'sysdba' password 'pass'")
con = interbase.create_database(dsn='/temp/db.interbase',user='sysdba',password='pass',page_size=8192)
interbase.load_api(ib_library_name=None, embedded=False)

Initializes bindings to InterBase Client Library unless they are already initialized. Called automatically by interbase.connect() and interbase.create_database().

Parameters:

ib_library_name (string) – (optional) Path to InterBase Client Library. When it’s not specified, interbase does its best to locate appropriate client library.

Returns:

interbase.ibase.ibclient_API instance.

Classes

Connection

class interbase.Connection(db_handle, dpb=None, sql_dialect=3, charset=None, isolation_level=b'\x03\t\x06\x0f\x11')

Represents a connection between the database client (the Python process) and the database server.

Important

DO NOT create instances of this class directly! Use only connect() or create_database() to get Connection instances.

Parameters:
  • db_handle – Database handle provided by factory function.

  • dpb – Database Parameter Block associated with database handle.

  • sql_dialect (integer) – SQL Dialect associated with database handle.

  • charset (string) – Character set associated with database handle.

exception DataError

Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range, etc.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception DatabaseError

Exception raised for errors that are related to the database.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception Error

Exception that is the base class of all other error exceptions. You can use this to catch all errors with one single ‘except’ statement. Warnings are not considered errors and thus should not use this class as base.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception IntegrityError

Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception InterfaceError

Exception raised for errors that are related to the database interface rather than the database itself.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception InternalError

Exception raised when the database encounters an internal error, e.g. the cursor is not valid anymore, the transaction is out of sync, etc.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception NotSupportedError

Exception raised in case a method or database API was used which is not supported by the database

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception OperationalError

Exception raised for errors that are related to the database’s operation and not necessarily under the control of the programmer, e.g. an unexpected disconnect occurs, the data source name is not found, a transaction could not be processed, a memory allocation error occurred during processing, etc.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception ProgrammingError

Exception raised for programming errors, e.g. table not found or already exists, syntax error in the SQL statement, wrong number of parameters specified, etc.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception Warning

Exception raised for important warnings like data truncations while inserting, etc.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

begin(tpb=None)

Starts a transaction explicitly. Operates on main_transaction. See Transaction.begin() for details.

Parameters:

tpb (TPB instance, list/tuple of isc_tpb_* constants or bytestring) – (Optional) Transaction Parameter Buffer for newly started transaction. If not specified, default_tpb is used.

close()

Close the connection now (rather than whenever __del__ is called). The connection will be unusable from this point forward; an Error (or subclass) exception will be raised if any operation is attempted with the connection. The same applies to all cursor and transaction objects trying to use the connection.

Also closes all EventConduit, Cursor and Transaction instances associated with this connection.

Raises:

ProgrammingError – When connection is a member of a ConnectionGroup.

commit(retaining=False)

Commit pending transaction to the database. Operates on main_transaction. See Transaction.commit() for details.

Parameters:

retaining (boolean) – (Optional) Indicates whether the transactional context of the transaction being resolved should be recycled.

Raises:

ProgrammingError – If Connection is closed.

create_savepoint(name)

Establishes a named SAVEPOINT for current transaction. Operates on main_transaction. See Transaction.savepoint() for details.

Parameters:

name (string) – Name for savepoint.

Raises:

ProgrammingError – If Connection is closed.

Example:

con.savepoint('BEGINNING_OF_SOME_SUBTASK')
...
con.rollback(savepoint='BEGINNING_OF_SOME_SUBTASK')
cursor()

Return a new Cursor instance using the connection associated with main_transaction. See Transaction.cursor() for details.

Raises:

ProgrammingError – If Connection is closed.

database_info(info_code, result_type)

Wraps the InterBase C API function isc_database_info.

For documentation, see the IB 6 API Guide section entitled “Requesting information about an attachment” (p. 51).

Note that this method is a VERY THIN wrapper around the IB C API function isc_database_info. This method does NOT attempt to interpret its results except with regard to whether they are a string or an integer.

For example, requesting isc_info_user_names will return a string containing a raw succession of length-name pairs. A thicker wrapper might interpret those raw results and return a Python tuple, but it would need to handle a multitude of special cases in order to cover all possible isc_info_* items.

Parameters:
  • info_code (integer) – One of the isc_info_* constants.

  • result_type (string) – Must be either ‘s’ if you expect a string result, or ‘i’ if you expect an integer result.

Raises:

See also

Extracting data with the database_info function is rather clumsy. See db_info() for higher-level means of accessing the same information.

Note

Some of the information available through this method would be more easily retrieved with the Services API (see submodule interbase.services).

db_info(request)

Higher-level convenience wrapper around the database_info() method that parses the output of database_info into Python-friendly objects instead of returning raw binary buffers in the case of complex result types.

Parameters:

request – Single interbase.isc_info_* info request code or a sequence of such codes.

Returns:

Mapping of (info request code -> result).

Raises:
drop_database()

Drops the database to which this connection is attached.

Unlike plain file deletion, this method behaves responsibly, in that it removes shadow files and other ancillary files for this database.

Raises:
event_conduit(event_names)

Creates a conduit through which database event notifications will flow into the Python program.

Parameters:

event_names – A sequence of string event names.

Returns:

An EventConduit instance.

execute_immediate(sql)

Executes a statement in context of main_transaction without caching its prepared form.

Automatically starts transaction if it’s not already started.

Parameters:

sql (string) – SQL statement to execute.

Important

The statement must not be of a type that returns a result set. In most cases (especially cases in which the same statement – perhaps a parameterized statement – is executed repeatedly), it is better to create a cursor using the connection’s cursor method, then execute the statement using one of the cursor’s execute methods.

Parameters:

sql (string) – SQL statement to execute.

Raises:
rollback(retaining=False, savepoint=None)

Causes the the database to roll back to the start of pending transaction. Operates on main_transaction. See Transaction.rollback() for details.

Parameters:
  • retaining (boolean) – (Optional) Indicates whether the transactional context of the transaction being resolved should be recycled.

  • savepoint (string) – (Optional) Causes the transaction to roll back only as far as the designated savepoint, rather than rolling back entirely.

Raises:

ProgrammingError – If Connection is closed.

trans(default_tpb=None)

Creates a new Transaction that operates within the context of this connection. Cursors can be created within that Transaction via its cursor() method.

Parameters:

default_tpb (TPB instance, list/tuple of isc_tpb_* constants or bytestring) – (optional) Transaction Parameter Block for newly created Transaction. If not specified, default_tpb is used.

Raises:

ProgrammingError – If Connection is closed.

trans_info(request)

Pythonic wrapper around transaction_info() call. Operates on main_transaction. See Transaction.trans_info() for details.

Parameters:

request – One or more information request codes (see transaction_info() for details). Multiple codes must be passed as tuple.

Returns:

Decoded response(s) for specified request code(s). When multiple requests are passed, returns a dictionary where key is the request code and value is the response from server.

Raises:
transaction_info(info_code, result_type)

Returns information about active transaction. Thin wrapper around InterBase API isc_transaction_info call. Operates on main_transaction. See Transaction.transaction_info() for details.

Parameters:
  • info_code (integer) –

    One from next constants:

    • isc_info_tra_id

    • isc_info_tra_oldest_interesting

    • isc_info_tra_oldest_snapshot

    • isc_info_tra_oldest_active

    • isc_info_tra_isolation

    • isc_info_tra_access

    • isc_info_tra_lock_timeout

    See InterBase API Guide for details.

  • result_type (string) –

    String code for result type:

    • ‘i’ for Integer

    • ‘s’ fro String

Returns:

Decoded response(s) for specified request code(s). When multiple requests are passed, returns a dictionary where key is the request code and value is the response from server.

Raises:
property charset

(Read Only) (string) Connection Character set name.

property closed

(Read Only) True if connection is closed.

property default_tpb

(Read/Write) Default Transaction Parameter Block used for all newly started transactions.

property engine_version

(Read Only) (float) InterBase version number of connected server. Only major.minor version.

property group

(Read Only) ConnectionGroup this Connection belongs to, or None.

property main_transaction

(Read Only) Main Transaction instance for this connection Connection methods begin(), savepoint(), commit() and rollback() are delegated to this transaction object.

property ods

(Read Only) (float) On-Disk Structure (ODS) version.

property query_transaction

(Read Only) Special “query” Transaction instance for this connection. This is ReadOnly ReadCommitted transaction that could be active indefinitely without blocking garbage collection. It’s used internally to query metadata, but it’s generally useful.

property schema

(Read Only) (Schema) Database metadata object.

property server_version

(Read Only) (string) Version string returned by server for this connection. This version string contains InterBase-friendly engine version number, i.e. version that takes into account inherited IB version number. For example it’s ‘LI-V6.3.2.26540 InterBase 2.5’ for InterBase 2.5.2

sql_dialect = 3

(integer) sql_dialect for this connection, do not change.

property transactions

(Read Only) (tuple) Transaction instances associated with this connection.

property version

(Read Only) (string) InterBase version number string of connected server. Uses InterBase version numbers in form: major.minor.subrelease.build

class interbase.ConnectionWithSchema(db_handle, dpb=None, sql_dialect=3, charset=None, isolation_level=b'\x03\t\x06\x0f\x11')

Connection descendant that exposes all attributes of encapsulated Schema instance directly as connection attributes, except close() and bind(), and those attributes that are already defined by Connection class.

Note

Use connection_class parameter of connect() or create_database() to create connections with direct schema interface.

Parameters:
  • db_handle – Database handle provided by factory function.

  • dpb – Database Parameter Block associated with database handle.

  • sql_dialect (integer) – SQL Dialect associated with database handle.

  • charset (string) – Character set associated with database handle.

property character_sets

List of all character sets in database. Items are CharacterSet objects.

property collations

List of all collations in database. Items are Collation objects.

property constraints

List of all constraints in database. Items are Constraint objects.

property default_character_set

Default CharacterSet for database

property dependencies

List of all dependencies in database. Items are Dependency objects.

property description

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

property domains

List of all user domains in database. Items are Domain objects.

property enum_character_set_names

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_field_subtypes

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_field_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_function_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_mechanism_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_object_type_codes

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_object_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_param_type_from

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_parameter_mechanism_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_procedure_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_relation_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_system_flag_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_transaction_state_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property enum_trigger_types

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property exceptions

List of all exceptions in database. Items are DatabaseException objects.

property files

List of all extension files defined for database. Items are DatabaseFile objects.

property functions

List of all user functions defined in database. Items are Function objects.

property generators

List of all user generators in database. Items are Sequence objects.

property indices

List of all user indices in database. Items are Index objects.

property opt_always_quote

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

property owner_name

Database owner name.

property privileges

List of all privileges defined for database. Items are Privilege objects.

property procedures

List of all user procedures in database. Items are Procedure objects.

property roles

List of all roles in database. Items are Role objects.

property security_class

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

property sequences

List of all user generators in database. Items are Sequence objects.

property shadows

List of all shadows defined for database. Items are Shadow objects.

property sysdomains

List of all system domains in database. Items are Domain objects.

property sysfunctions

List of all system functions defined in database. Items are Function objects.

property sysgenerators

List of all system generators in database. Items are Sequence objects.

property sysindices

List of all system indices in database. Items are Index objects.

property sysprocedures

List of all system procedures in database. Items are Procedure objects.

property syssequences

List of all system generators in database. Items are Sequence objects.

property systables

List of all system tables in database. Items are Table objects.

property systriggers

List of all system triggers in database. Items are Trigger objects.

property sysviews

List of all system views in database. Items are View objects.

property tables

List of all user tables in database. Items are Table objects.

property triggers

List of all user triggers in database. Items are Trigger objects.

property views

List of all user views in database. Items are View objects.

Note

For list of methods see interbase.schema.Schema.

Cursor

class interbase.Cursor(connection, transaction)

Represents a database cursor, which is used to execute SQL statement and manage the context of a fetch operation.

Important

DO NOT create instances of this class directly! Use only Connection.cursor(), Transaction.cursor() and ConnectionGroup.cursor() to get Cursor instances that operate in desired context.

Note

Cursor is actually a high-level wrapper around PreparedStatement instance(s) that handle the actual SQL statement execution and result management.

Tip

Cursor supports the iterator protocol, yielding tuples of values like fetchone().

Important

The association between a Cursor and its Transaction and Connection is set when the Cursor is created, and cannot be changed during the lifetime of that Cursor.

Parameters:
  • connectionConnection instance this cursor should be bound to.

  • transactionTransaction instance this cursor should be bound to.

callproc(procname, parameters=None)

Call a stored database procedure with the given name.

The result of the call is available through the standard fetchXXX() methods.

Parameters:
  • procname (string) – Stored procedure name.

  • parameters (List or Tuple) – (Optional) Sequence of parameters. Must contain one entry for each argument that the procedure expects.

Returns:

parameters, as required by Python DB API 2.0 Spec.

Raises:
close()

Close the cursor now (rather than whenever __del__ is called).

Closes any currently open PreparedStatement. However, the cursor is still bound to Connection and Transaction, so it could be still used to execute SQL statements. Also the cache with prepared statements is left intact.

Warning

Interbase’s implementation of Cursor somewhat violates the Python DB API 2.0, which requires that cursor will be unusable after call to close; and an Error (or subclass) exception should be raised if any operation is attempted with the cursor.

If you’ll take advantage of this anomaly, your code would be less portable to other Python DB API 2.0 compliant drivers.

execute(operation, parameters=None)

Prepare and execute a database operation (query or command).

Note

Execution is handled by PreparedStatement that is either supplied as operation parameter, or created internally when operation is a string. Internally created PreparedStatements are stored in cache for later reuse, when the same operation string is used again.

Returns:

self, so call to execute could be used as iterator.

Parameters:
  • operation (string or PreparedStatement instance) – SQL command specification.

  • parameters (List or Tuple) – (Optional) Sequence of parameters. Must contain one entry for each argument that the operation expects.

Raises:
  • ValueError – When operation PreparedStatement belongs to different Cursor instance.

  • TypeError – When parameters is not List or Tuple.

  • ProgrammingError – When more parameters than expected are supplied.

  • DatabaseError – When error is returned by server.

executemany(operation, seq_of_parameters)

Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.

Note

This function simply calls execute() in a loop, feeding it with parameters from seq_of_parameters. Because execute caches PreparedStatements, calling executemany is equally efective as direct use of prepared statement and calling execute in a loop directly in application.

Returns:

self, so call to executemany could be used as iterator.

Parameters:
  • operation (string or PreparedStatement instance) – SQL command specification.

  • seq_of_parameters (List or Tuple) – Sequence of sequences of parameters. Must contain one sequence of parameters for each execution that has one entry for each argument that the operation expects.

Raises:
  • ValueError – When operation PreparedStatement belongs to different Cursor instance.

  • TypeError – When seq_of_parameters is not List or Tuple.

  • ProgrammingError – When there are more parameters in any sequence than expected.

  • DatabaseError – When error is returned by server.

fetchall()

Fetch all (remaining) rows of a query result.

Returns:

List of tuples, where each tuple is one row of returned values.

Raises:
fetchallmap()

Fetch all (remaining) rows of a query result like fetchall(), except that it returns a list of mappings of field name to field value, rather than a list of tuples.

Returns:

List of ibcore._RowMapping instances, one such instance for each row.

Raises:
fetchmany(size=None)

Fetch the next set of rows of a query result, returning a sequence of sequences (e.g. a list of tuples). An empty sequence is returned when no more rows are available. The number of rows to fetch per call is specified by the parameter. If it is not given, the cursor’s arraysize determines the number of rows to be fetched. The method does try to fetch as many rows as indicated by the size parameter. If this is not possible due to the specified number of rows not being available, fewer rows may be returned.

Parameters:

size (integer) – Max. number of rows to fetch.

Returns:

List of tuples, where each tuple is one row of returned values.

Raises:
fetchmanymap(size=None)

Fetch the next set of rows of a query result, like fetchmany(), except that it returns a list of mappings of field name to field value, rather than a list of tuples.

Parameters:

size (integer) – Max. number of rows to fetch.

Returns:

List of ibcore._RowMapping instances, one such instance for each row.

Raises:
fetchone()

Fetch the next row of a query result set.

Returns:

tuple of returned values, or None when no more data is available.

Raises:
fetchonemap()

Fetch the next row of a query result set like fetchone(), except that it returns a mapping of field name to field value, rather than a tuple.

Returns:

ibcore._RowMapping of returned values, or None when no more data is available.

Raises:
iter()

Equivalent to the fetchall(), except that it returns iterator rather than materialized list.

Returns:

Iterator that yields tuple of values like fetchone().

itermap()

Equivalent to the fetchallmap(), except that it returns iterator rather than materialized list.

Returns:

Iterator that yields ibcore._RowMapping instance like fetchonemap().

next()

Return the next item from the container. Part of iterator protocol.

Raises:

StopIteration – If there are no further items.

prep(operation)

Create prepared statement for repeated execution.

Note

Returned PreparedStatement instance is bound to its Cursor instance via strong reference, and is not stored in Cursor’s internal cache of prepared statements.

Parameters:

operation (string) – SQL command

Returns:

PreparedStatement instance.

Raises:
set_stream_blob(blob_name)

Specify a BLOB column(s) to work in stream mode instead classic, materialized mode for already executed statement.

Parameters:

blob_name (string or sequence) – Single name or sequence of column names. Name must be in format as it’s stored in database (refer to description for real value).

Important

BLOB name is permanently added to the list of BLOBs handled as stream BLOBs by current PreparedStatement instance. If instance is stored in internal cache of prepared statements, the same command executed repeatedly will retain this setting.

Parameters:

blob_name (string) – Name of BLOB column.

Raises:

ProgrammingError

setinputsizes(sizes)

Required by Python DB API 2.0, but pointless for InterBase, so it does nothing.

setoutputsize(size, column=None)

Required by Python DB API 2.0, but pointless for InterBase, so it does nothing.

property connection

(Read Only) (Connection) PEP 249 Extension. Reference to the Connection object on which the cursor was created.

property description

(Read Only) Sequence of 7-item sequences. Each of these sequences contains information describing one result column: (name, type_code, display_size,internal_size, precision, scale, null_ok)

If cursor doesn’t have a prepared statement, the value is None.

property name

(Read/Write) (string) Name for the SQL cursor. This property can be ignored entirely if you don’t need to use it.

property plan

(Read Only) (string) A string representation of the execution plan for last executed statement generated by the database engine’s optimizer. None if no statement was executed.

property rowcount

(Read Only) (integer) Specifies the number of rows that the last executeXXX() produced (for DQL statements like select) or affected (for DML statements like update or insert ).

The attribute is -1 in case no executeXXX() has been performed on the cursor or the rowcount of the last operation is not determinable by the interface.

Note

The database engine’s own support for the determination of “rows affected”/”rows selected” is quirky. The database engine only supports the determination of rowcount for INSERT, UPDATE, DELETE, and SELECT statements. When stored procedures become involved, row count figures are usually not available to the client. Determining rowcount for SELECT statements is problematic: the rowcount is reported as zero until at least one row has been fetched from the result set, and the rowcount is misreported if the result set is larger than 1302 rows. The server apparently marshals result sets internally in batches of 1302, and will misreport the rowcount for result sets larger than 1302 rows until the 1303rd row is fetched, result sets larger than 2604 rows until the 2605th row is fetched, and so on, in increments of 1302.

property transaction

(Read Only) (Transaction) Reference to the Transaction object on which the cursor was created.

Transaction

class interbase.Transaction(connections, default_tpb=None, default_action='commit')

Represents a transaction context, which is used to execute SQL statement.

Important

DO NOT create instances of this class directly! Connection and ConnectionGroup manage Transaction internally, surfacing all important methods directly in their interfaces. If you want additional transactions independent from Connection.main_transaction, use Connection.trans() method to obtain such Transaction instance.

Parameters:
  • connections (iterable) – Sequence of (up to 16) Connection instances.

  • default_tpb (TPB instance, list/tuple of isc_tpb_* constants or bytestring) – Transaction Parameter Block for this transaction. If None is specified, uses ISOLATION_LEVEL_READ_COMMITED.

  • default_action (string 'commit' or 'rollback') – Action taken when active transaction is ended automatically (during close() or begin()).

Raises:

ProgrammingError – When zero or more than 16 connections are given.

begin(tpb=None)

Starts a transaction explicitly.

Parameters:

tpb (TPB instance, list/tuple of isc_tpb_* constants or bytestring) – (optional) Transaction Parameter Block for newly created Transaction. If not specified, default_tpb is used.

Note

Calling this method directly is never required; a transaction will be started implicitly if necessary.

Important

If the physical transaction is unresolved when this method is called, a commit() or rollback() will be performed first, accordingly to default_action value.

Raises:
close()

Permanently closes the Transaction object and severs its associations with other objects (Cursor and Connection instances).

Important

If the physical transaction is unresolved when this method is called, a commit() or rollback() will be performed first, accordingly to default_action value.

commit(retaining=False)

Commit any pending transaction to the database.

Note

If transaction is not active, this method does nothing, because the consensus among Python DB API experts is that transactions should always be started implicitly, even if that means allowing a commit() or rollback() without an actual transaction.

Parameters:

retaining (boolean) – Indicates whether the transactional context of the transaction being resolved should be recycled.

Raises:

DatabaseError – When error is returned by server as response to commit.

create_savepoint(name)

Establishes a savepoint with the specified name.

Note

If transaction is bound to multiple connections, savepoint is created on all of them.

Parameters:

name (string) – Savepoint name.

cursor(connection=None)

Creates a new Cursor that will operate in the context of this Transaction.

Parameters:

connection (Connection instance) – Required only when Transaction is bound to multiple Connections, to specify to which Connection the returned Cursor should be bound.

Raises:

ProgrammingError – When transaction operates on multiple Connections and: connection parameter is not specified, or specified connection is not among Connections this Transaction is bound to.

execute_immediate(sql)
Executes a statement without caching its prepared form on

all connections this transaction is bound to.

Automatically starts transaction if it’s not already started.

Parameters:

sql (string) – SQL statement to execute.

Important

The statement must not be of a type that returns a result set. In most cases (especially cases in which the same statement – perhaps a parameterized statement – is executed repeatedly), it is better to create a cursor using the connection’s cursor method, then execute the statement using one of the cursor’s execute methods.

Parameters:

sql (string) – SQL statement to execute.

Raises:

DatabaseError – When error is returned from server.

prepare()

Manually triggers the first phase of a two-phase commit (2PC).

Note

Direct use of this method is optional; if preparation is not triggered manually, it will be performed implicitly by commit() in a 2PC.

release_savepoint(name)

Description: Releasing a savepoint destroys savepoint named by the identifier without affecting any work that has been performed subsequent to its creation.

Parameters:

name (string) – savepoint_name

rollback(retaining=False, savepoint=None)

Rollback any pending transaction to the database.

Note

If transaction is not active, this method does nothing, because the consensus among Python DB API experts is that transactions should always be started implicitly, even if that means allowing a commit() or rollback() without an actual transaction.

Parameters:
  • retaining (boolean) – Indicates whether the transactional context of the transaction being resolved should be recycled. Mutually exclusive with ‘savepoint`.

  • savepoint (string) – Savepoint name. Causes the transaction to roll back only as far as the designated savepoint, rather than rolling back entirely. Mutually exclusive with ‘retaining`.

Raises:
  • ProgrammingError – If both savepoint and retaining are specified.

  • DatabaseError – When error is returned by server as response to rollback.

trans_info(request)

Pythonic wrapper around transaction_info() call.

Parameters:

request – One or more information request codes (see transaction_info() for details). Multiple codes must be passed as tuple.

Returns:

Decoded response(s) for specified request code(s). When multiple requests are passed, returns a dictionary where key is the request code and value is the response from server.

transaction_info(info_code, result_type)

Return information about active transaction.

This is very thin wrapper around InterBase API isc_transaction_info call.

Parameters:
  • info_code (integer) – One from the isc_info_tra_* constants.

  • result_type (string 's' or 'i') – Code for result type.

Raises:
property active

(Read Only) True if transaction is active.

property closed

(Read Only) True if transaction is closed.

property cursors

(Read Only) List of Cursor objects associated with this Transaction.

property default_action

(Read/Write) (string) ‘commit’ or ‘rollback’, action to be taken when physical transaction has to be ended automatically. Default is ‘commit’.

default_tpb = b'\x03\t\x06\x0f\x11'

(Read/Write) Transaction Parameter Block.

PreparedStatement

class interbase.PreparedStatement(operation, cursor, internal=True)

Represents a prepared statement, an “inner” database cursor, which is used to manage the SQL statement execution and context of a fetch operation.

Important

DO NOT create instances of this class directly! Use only Cursor.prep() to get PreparedStatement instances.

Note

PreparedStatements are bound to Cursor instance that created them, and using them with other Cursor would report an error.

close()

Drops the resources associated with executed prepared statement, but keeps it prepared for another execution.

set_stream_blob(blob_name)

Specify a BLOB column(s) to work in stream mode instead classic, materialized mode.

Parameters:

blob_name (string or sequence) – Single name or sequence of column names. Name must be in format as it’s stored in database (refer to description for real value).

Important

BLOB name is permanently added to the list of BLOBs handled as stream BLOBs by this instance.

Parameters:

blob_name (string) – Name of BLOB column.

NO_FETCH_ATTEMPTED_YET = -1

Constant for internal use by this class. Do not change!

RESULT_SET_EXHAUSTED = 100

Constant for internal use by this class. Do not change!

property closed

(Read Only) (boolean) True if closed. Note that closed means that PS statement handle was closed for further fetching, releasing server resources, but wasn’t dropped, and could be still used for another execution.

cursor = None

Cursor instance that manages this PreparedStatement. Do not change!

property description

(Read Only) Sequence of 7-item sequences. Each of these sequences contains information describing one result column: (name, type_code, display_size,internal_size, precision, scale, null_ok)

n_input_params = 0

The number of input parameters the statement requires. Do not change!

n_output_params = 0

The number of output fields the statement produces. Do not change!

property name

(Read/Write) (string) Name for the SQL cursor. This property can be ignored entirely if you don’t need to use it.

property plan

(Read Only) (string) A string representation of the execution plan generated for this statement by the database engine’s optimizer.

property rowcount

(Read Only) (integer) Specifies the number of rows that the last execution produced (for DQL statements like select) or affected (for DML statements like update or insert ).

The attribute is -1 in case the statement was not yet executed or the rowcount of the operation is not determinable by the interface.

property sql

(Read Only) (string) SQL command this PreparedStatement executes.

statement_type = 0

(integer) An integer code that can be matched against the statement type constants in the isc_info_sql_stmt_* series. Do not change!

ConnectionGroup

class interbase.ConnectionGroup(connections=())

Manager for distributed transactions, i.e. transactions that span multiple databases.

Tip

ConnectionGroup supports in operator to check membership of connections.

Parameters:

connections (iterable) – Sequence of Connection instances.

See also

See add() for list of exceptions the constructor may throw.

add(con)

Adds active connection to the group.

Parameters:

con – A Connection instance to add to this group.

Raises:
  • TypeError – When con is not Connection instance.

  • ProgrammingError – When con is already member of this or another group, or closed. When this group has unresolved transaction or contains 16 connections.

begin(tpb=None)

Starts distributed transaction over member connections.

Parameters:

tpb (TPB instance, list/tuple of isc_tpb_* constants or bytestring) – (Optional) Transaction Parameter Buffer for newly started transaction. If not specified, default_tpb is used.

Raises:

ProgrammingError – When group is empty or has active transaction.

clear()

Removes all connections from group.

Raises:

ProgrammingError – When transaction is active.

commit(retaining=False)

Commits distributed transaction over member connections using 2PC.

Note

If transaction is not active, this method does nothing, because the consensus among Python DB API experts is that transactions should always be started implicitly, even if that means allowing a commit() or rollback() without an actual transaction.

Parameters:

retaining (boolean) – Indicates whether the transactional context of the transaction being resolved should be recycled.

Raises:

ProgrammingError – When group is empty.

contains(con)

Returns True if specified connection belong to this group.

Parameters:

conConnection instance.

count()

Returns number of Connection objects that belong to this group.

create_savepoint(name)

Establishes a named SAVEPOINT on all member connections. See Transaction.savepoint() for details.

Parameters:

name (string) – Name for savepoint.

Raises:

ProgrammingError – When group is empty.

cursor(connection)

Creates a new Cursor that will operate in the context of distributed transaction and specific Connection that belongs to this group.

Note

Automatically starts transaction if it’s not already started.

Parameters:

connectionConnection instance.

Raises:

ProgrammingError – When group is empty or specified connection doesn’t belong to this group.

disband()

Forcefully deletes all connections from connection group.

Note

If transaction is active, it’s canceled (rollback).

Note

Any error during transaction finalization doesn’t stop the disband process, however the exception catched is eventually reported.

execute_immediate(sql)

Executes a statement on all member connections without caching its prepared form.

Automatically starts transaction if it’s not already started.

Parameters:

sql (string) – SQL statement to execute.

Important

The statement must not be of a type that returns a result set. In most cases (especially cases in which the same statement – perhaps a parameterized statement – is executed repeatedly), it is better to create a cursor using the connection’s cursor method, then execute the statement using one of the cursor’s execute methods.

Parameters:

sql (string) – SQL statement to execute.

Raises:

DatabaseError – When error is returned from server.

members()

Returns list of connection objects that belong to this group.

prepare()

Manually triggers the first phase of a two-phase commit (2PC). Use of this method is optional; if preparation is not triggered manually, it will be performed implicitly by commit() in a 2PC.

release_savepoint(name)

Description: Releasing a savepoint destroys savepoint named by the identifier without affecting any work that has been performed subsequent to its creation.

Parameters:

name (string) – Name for savepoint.

Raises:

ProgrammingError – When group is empty.

remove(con)

Removes specified connection from group.

Parameters:

con – A Connection instance to remove.

Raises:

ProgrammingError – When con doesn’t belong to this group or transaction is active.

rollback(retaining=False, savepoint=None)

Rollbacks distributed transaction over member connections.

Note

If transaction is not active, this method does nothing, because the consensus among Python DB API experts is that transactions should always be started implicitly, even if that means allowing a commit() or rollback() without an actual transaction.

Parameters:

retaining (boolean) – Indicates whether the transactional context of the transaction being resolved should be recycled.

Raises:

ProgrammingError – When group is empty.

property default_tpb

(Read/Write) Default Transaction Parameter Block used for transactions.

TransactionContext

class interbase.TransactionContext(transaction)

Context Manager that manages transaction for object passed to constructor.

Performs rollback if exception is thrown inside code block, otherwise performs commit at the end of block.

Example:

with TransactionContext(my_transaction):
    cursor.execute('insert into tableA (x,y) values (?,?)',(x,y))
    cursor.execute('insert into tableB (x,y) values (?,?)',(x,y))
Parameters:

transaction – Any object that supports begin(), commit() and rollback().

transaction = None

Transaction-like object this instance manages.

EventConduit

class interbase.EventConduit(db_handle, event_names)

Represents a conduit through which database event notifications will flow into the Python program.

Important

DO NOT create instances of this class directly! Use only Connection.event_conduit() to get EventConduit instances.

Notifications of any events are not accumulated until begin() method is called.

From the moment the begin() method is called, notifications of any events that occur will accumulate asynchronously within the conduit’s internal queue until the conduit is closed either explicitly (via the close() method) or implicitly (via garbage collection).

EventConduit implements context manager protocol to call method begin() and close() automatically.

Example:

with connection.event_conduit( ('event_a', 'event_b') ) as conduit:
    events = conduit.wait()
    process_events(events)
Parameters:
  • db_handle – Database handle.

  • event_names – List of strings that represent event names.

begin()

Starts listening for events.

Must be called directly or through context manager interface.

close()

Cancels the standing request for this conduit to be notified of events.

After this method has been called, this EventConduit object is useless, and should be discarded.

flush()

Clear any event notifications that have accumulated in the conduit’s internal queue.

wait(timeout=None)

Wait for events.

Blocks the calling thread until at least one of the events occurs, or the specified timeout (if any) expires.

Parameters:

timeout (integer or float) – Number of seconds (use a float to indicate fractions of seconds). If not even one of the relevant events has occurred after timeout seconds, this method will unblock and return None. The default timeout is infinite.

Returns:

None if the wait timed out, otherwise a dictionary that maps event_name -> event_occurrence_count.

Example:

>>>conduit = connection.event_conduit( ('event_a', 'event_b') )
>>>conduit.begin()
>>>conduit.wait()
{
 'event_a': 1,
 'event_b': 0
}

In the example above event_a occurred once and event_b did not occur at all.

property closed

(Read Only) (boolean) True if conduit is closed.

BlobReader

class interbase.BlobReader(blobid, db_handle, tr_handle, is_text, charset)

BlobReader is a “file-like” class, so it acts much like a file instance opened in rb mode.

Important

DO NOT create instances of this class directly! BlobReader instances are returned automatically in place of output BLOB values when stream BLOB access is requested via PreparedStatement.set_stream_blob().

Tip

BlobReader supports iterator protocol, yielding lines like readline().

close()

Closes the Reader. Like file.close().

Raises:

DatabaseError – When error is returned by server.

flush()

Flush the internal buffer. Like file.flush(). Does nothing as it’s pointless for reader.

next()

Return the next line from the BLOB. Part of iterator protocol.

Raises:

StopIteration – If there are no further lines.

read(size=-1)

Read at most size bytes from the file (less if the read hits EOF before obtaining size bytes). If the size argument is negative or omitted, read all data until EOF is reached. The bytes are returned as a string object. An empty string is returned when EOF is encountered immediately. Like file.read().

Raises:

ProgrammingError – When reader is closed.

Note

Performs automatic conversion to unicode for TEXT BLOBs, if used Python is v3 or connection charset is defined.

readline()

Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). An empty string is returned when EOF is encountered immediately. Like file.readline().

Raises:

ProgrammingError – When reader is closed.

Note

Performs automatic conversion to unicode for TEXT BLOBs, if used Python is v3 or connection charset is defined.

readlines(sizehint=None)

Read until EOF using readline() and return a list containing the lines thus read. The optional sizehint argument (if present) is ignored. Like file.readlines().

Note

Performs automatic conversion to unicode for TEXT BLOBs, if used Python is v3 or connection charset is defined.

seek(offset, whence=0)

Set the file’s current position, like stdio‘s fseek(). See file.seek() details.

Parameters:
  • offset (integer) – Offset from specified position.

  • whence (os.SEEK_SET, os.SEEK_CUR or os.SEEK_END) – (Optional) Context for offset.

Raises:

ProgrammingError – When reader is closed.

Warning

If BLOB was NOT CREATED as stream BLOB, this method raises DatabaseError exception. This constraint is set by InterBase.

tell()

Return current position in BLOB, like stdio‘s ftell() and file.tell().

property closed

(Read Only) (boolean) True is BlobReader is closed.

property mode

(Read Only) (string) File mode - always “rb”

TPB

class interbase.TPB

Helper class for convenient and safe construction of custom Transaction Parameter Blocks.

copy()

Returns a copy of self.

render()

Create valid transaction parameter block according to current values of member attributes.

Returns:

(string) TPB block.

property access_mode

(integer) Required access mode (isc_tpb_read or isc_tpb_write). Default: isc_tpb_write

property isolation_level

(integer or tuple) Required Transaction Isolation Level. Single integer value equivalent to isc_tpb_concurrency or isc_tpb_consistency, or tuple of exactly two integer values, where the first one is isc_tpb_read_committed and second either isc_tpb_rec_version or isc_tpb_no_rec_version.

When value isc_tpb_read_committed is assigned without suboption, the isc_tpb_rec_version is assigned as default suboption.

Default: isc_tpb_concurrency

property lock_resolution

(integer) Required lock resolution method. Either isc_tpb_wait or isc_tpb_nowait.

Default: isc_tpb_wait

property lock_timeout

(integer) Required lock timeout or None.

Default: None

property table_reservation

(TableReservation) Table reservation specification.

Default: None.

Instead of changing the value of the TableReservation object itself, you must change its elements by manipulating it as though it were a dictionary that mapped “TABLE_NAME”: (sharingMode, accessMode) For example:

tpb.table_reservation["MY_TABLE"] = (interbase.isc_tpb_protected, interbase.isc_tpb_lock_write)

TableReservation

class interbase.TableReservation

A dictionary-like helper class that maps “TABLE_NAME”: (sharingMode, accessMode). It performs validation of values assigned to keys.

copy()
get(key, default=None)
items()
iteritems()
iterkeys()
itervalues()
keys()
render()

Create valid table access parameter block according to current key/value pairs.

Returns:

(string) Table access definition block.

values()

Internally used classes exposed to driver users

RowMapping

class interbase.ibcore._RowMapping(description, row)

An internal dictionary-like class that wraps a row of results in order to map field name to field value.

Warning

We make ABSOLUTELY NO GUARANTEES about the return value of the fetch(one|many|all) methods except that it is a sequence indexed by field position, and no guarantees about the return value of the fetch(one|many|all)map methods except that it is a mapping of field name to field value.

Therefore, client programmers should NOT rely on the return value being an instance of a particular class or type.

get(fieldName, defaultValue=None)
items()
iteritems()
iterkeys()
itervalues()
keys()
values()

EventBlock

class interbase.ibcore.EventBlock(queue, db_handle, event_names)

Represents InterBase API structure for block of events.

close()

Close this block canceling managed events.

count_and_reregister()

Count event occurrences and re-register interest in further notifications.

buf_length = 0

length of internal event buffer

property closed

(ReadOnly) True if block is closed for business

event_buf = None

Event buffer

event_id = 0

Event ID

event_names = []

List of registered event names

result_buf = None

Result buffer

Services

Module globals

interbase.services.SHUT_LEGACY
interbase.services.SHUT_NORMAL
interbase.services.SHUT_MULTI
interbase.services.SHUT_SINGLE
interbase.services.SHUT_FULL

These constants are to be passed as the shutdown_mode parameter to Connection.shutdown() and Connection.bring_online().

interbase.services.SHUT_FORCE
interbase.services.SHUT_DENY_NEW_TRANSACTIONS
interbase.services.SHUT_DENY_NEW_ATTACHMENTS

These constants are to be passed as the shutdown_method parameter to Connection.shutdown()

interbase.services.WRITE_FORCED
interbase.services.WRITE_BUFFERED

These constants are to be passed as the mode parameter to Connection.setWriteMode()

interbase.services.ACCESS_READ_WRITE
interbase.services.ACCESS_READ_ONLY

These constants are to be passed as the mode parameter to Connection.setAccessMode()

interbase.services.CAPABILITY_MULTI_CLIENT
interbase.services.CAPABILITY_REMOTE_HOP
interbase.services.CAPABILITY_SERVER_CONFIG
interbase.services.CAPABILITY_QUOTED_FILENAME
interbase.services.CAPABILITY_NO_SERVER_SHUTDOWN

These constants are return values of Connection.get_server_capabilities()

Functions

interbase.services.connect(host=None, user='sysdba', password=None, enc_password=None, sep_password=None, ssl=None, ib_library_name=None, server_public_file=None, client_pass_phrase=None, client_pass_phrase_file=None, server_public_path=None, client_cert_file=None, embedded=False)

Establishes a connection to the Services Manager.

Parameters:
  • host (string) – (optional) Host machine specification. Local by default.

  • user (string) – (optional) Administrative user name. Defaults to content of environment variable ‘ISC_USER’ or ‘SYSDBA’.

  • password (string) – Administrative user password. Default is content of environment variable ‘ISC_PASSWORD’.

  • enc_password (string) – Encrypted password.

  • sep_password (string) – Database system encryption password.

  • ssl (bool) – Enable ssl connection to database.

  • ib_library_name (string) – Full path to InterBase client library. See load_api() for details.

  • server_public_file (string) – server public file

  • client_private_file (string) – client private file.

  • client_pass_phrase (string) – Passphrase

  • client_pass_phrase_file (string) – File with pass phrase.

  • server_public_path (string) – Server public path.

  • client_cert_file (string) – Client cert file.

  • embedded (bool) – Load embedded version of the driver.

Note

By definition, a Services Manager connection is bound to a particular host. Therefore, the database specified as a parameter to methods such as getStatistics MUST NOT include the host name of the database server.

Connection

class interbase.services.Connection(host, user, password, charset=None, enc_password=None, sep_password=None)

Represents a service connection between the database client (the Python process) and the database server.

Important

DO NOT create instances of this class directly! Use only connect() to get Connection instances.

Tip

Connection supports the iterator protocol, yielding lines of result like readline().

activate_shadow(database)

Activate Database Shadow(s).

Parameters:

database (string) – Database filename or alias.

add_db_alias(alias: str, path: str) None

Add an alias for the database to the server; only SYSDBA can invoke this task.

Parameters:
  • alias (string) – Name of future alias

  • path (string) – Path to database

Returns None:

add_user(user)

Add new user.

Parameters:

user (User) – Instance of User with at least its name and password attributes specified as non-empty values. All other attributes are optional.

Note

This method ignores the user_id and group_id attributes of User regardless of their values.

archive_backup(db_path: str, journal: bool = False, callback=None)

This function execute archive journal/database operation. This operation is equivalent to the “gbak -archive_database” command.

Parameters:
  • db_path (string) – Path to primary database

  • journal (bool) – Run journal archive (default value is False).

  • callback (function) – Function to call back with each output line. Function must accept only one parameter: line of output.

Important

journal and database switches will raise conflict if they both True

archive_restore(bkp_file: str, spb_dbname: str, recover_until: str | None = None, callback=None)

Request to execute an Archive Recover operation and recover from a database archive in the journal archive directory location.

Parameters:

bkp_file (string) – Path of the database in the Journal Archive location,

from the point of view of the server. The database file mentioned will be used as the source database. to recover from followed by recovering data from associated journals from the same archive location. :param string spb_dbname: Path of the database file to restore, from the point of view of the server. The newly restored database once fully recovered will be set to “read_only” mode and can be brought back online later. :param recover_until: Point-in-time-recovery; this operation is equivalent to “gbak -until <timestamp>” command. Argument value is Python datetime.

If callback is not specified, backup log could be retrieved through readline(), readlines(), iteration over Connection or ignored via call to wait().

backup(source_database, dest_filenames, dest_file_sizes=(), ignore_checksums=0, ignore_limbo_transactions=0, metadata_only=0, collect_garbage=1, transportable=1, convert_external_tables_to_internal=0, compressed=1, no_db_triggers=0, sep_password=None, encrypt_name=None, callback=None)

Request logical (GBAK) database backup. (ASYNC service)

Parameters:
  • source_database (string) – Source database specification.

  • dest_filenames (string or tuple of strings) – Backup file(s) specification.

  • dest_file_sizes (tuple of integers) – (optional) specification of backup file max. sizes.

  • ignore_checksums (integer) – 1 to ignore checksums.

  • ignore_limbo_transactions (integer) – 1 to ignore limbo transactions.

  • metadata_only (integer) – 1 to create only metadata backup.

  • collect_garbage (integer) – 0 to skip garbage collection.

  • transportable (integer) – 0 to do not create transportable backup.

  • convert_external_tables_to_internal (integer) – 1 to convert external table to internal ones.

  • compressed (integer) – 0 to create uncompressed backup.

  • no_db_triggers (integer) – 1 to disable database triggers temporarily.

  • callback (function) – Function to call back with each output line. Function must accept only one parameter: line of output.

  • sep_password (string) – SEP database password.

  • encrypt_name (string) – The encryption key/name.

If callback is not specified, backup log could be retrieved through readline(), readlines(), iteration over Connection or ignored via call to wait().

Note

Until backup report is not fully fetched from service (or ignored via wait()), any attempt to start another asynchronous service will fail with exception.

backup_tablespace(db_path: str, tablespace_name: str, bkp_file: str, callback=None)

Create a single tablespace backup file

Parameters:
  • db_path (string) – path to database

  • tablespace_name (string) – exist table space in database

  • bkp_file (string) – Path to created bk file.

bring_online(database, online_mode=0)

Bring previously shut down database back online.

Parameters:

See also

See also shutdown() method.

close()

Close the connection now (rather than whenever __del__ is called). The connection will be unusable from this point forward; an Error (or subclass) exception will be raised if any operation is attempted with the connection.

commit_limbo_transaction(database, transaction_id)

Resolve limbo transaction with commit.

Parameters:
  • database (string) – Database filename or alias.

  • transaction_id (integer) – ID of Transaction to resolve.

create_dump(db_name: str, dump_file: str, overwrite: bool = False)

Request to the Services Manager perform a dump operation. This is a programmatic method to invoke the gbak tool as a thread in the ibserver process. You must specify the absolute full path(or alias) of the database primary file, and the dump output file or files. Because the Services Manager executes dump tasks on the server host, the Services Manager reads and writes dump files on the server host. The Services Manager also creates files in the context of the server.

Parameters:
  • db_name (string) – Full path to database or alias name.

  • dump_file (string) – Path to future dump file.

Returns None:

delete_db_alias(alias: str) None

Deletes an existing database alias.

Parameters:

alias (string) – Alias name

Returns None:

get_architecture()

Get InterBase Server architecture.

Returns string:

Architecture (example: ‘InterBase/Linux AMD64’).

get_attached_database_names()

Get list of attached databases.

Returns list:

Filenames of attached databases.

get_connection_count()

Get number of attachments to server.

Returns integer:

Directory path.

get_db_alias() dict

Returns a list with existing database alias.

Returns dict:

Dict with all database aliases (example: {‘alias_name’: ‘database_path’}).

get_home_directory()

Get InterBase Home (installation) Directory.

Returns string:

Directory path.

get_limbo_transaction_ids(database)

Get list of transactions in limbo.

Parameters:

database (string) – Database filename or alias.

Returns list:

Transaction IDs.

Raises:

InternalError – When can’t process the result buffer.

get_lock_file_directory()

Get directory location for InterBase lock files.

Returns string:

Directory path.

get_log(callback=None)

Request content of InterBase Server log. (ASYNC service)

Parameters:

callback (function) – Function to call back with each output line. Function must accept only one parameter: line of output.

If callback is not specified, log content could be retrieved through readline(), readlines(), iteration over Connection or ignored via call to wait().

Note

Until log content is not fully fetched from service (or ignored via wait()), any attempt to start another asynchronous service will fail with exception.

get_message_file_directory()

Get directory with InterBase message file.

Returns string:

Directory path.

get_security_database_path()

Get full path to InterBase security database.

Returns string:

Path (path+filename) to security database.

get_server_capabilities()

Get list of InterBase capabilities.

Returns tuple:

Capability info codes for each capability reported by server.

Next interbase.services constants define possible info codes returned:

CAPABILITY_MULTI_CLIENT
CAPABILITY_REMOTE_HOP
CAPABILITY_SERVER_CONFIG
CAPABILITY_QUOTED_FILENAME
CAPABILITY_NO_SERVER_SHUTDOWN

Example:

>>>interbase.services.CAPABILITY_REMOTE_HOP in svc.get_server_capabilities()
True
get_server_version()

Get InterBase version.

Returns string:

InterBase version (example: ‘LI-V2.5.2.26536 InterBase 2.5’).

get_service_manager_version()

Get InterBase Service Manager version number.

Returns integer:

Version number.

get_statistics(database, show_only_db_log_pages=0, show_only_db_header_pages=0, show_user_data_pages=1, show_user_index_pages=1, show_system_tables_and_indexes=0, show_record_versions=0, callback=None)

Request database statisctics. (ASYNC service)

Parameters:
  • database (string) – Database specification.

  • show_only_db_log_pages (integer) – 1 to analyze only log pages.

  • show_only_db_header_pages (integer) – 1 to analyze only database header. When set, all other parameters are ignored.

  • show_user_data_pages (integer) – 0 to skip user data analysis.

  • show_user_index_pages (integer) – 0 to skip user index analysis.

  • show_system_tables_and_indexes (integer) – 1 to analyze system tables and indices.

  • show_record_versions (integer) – 1 to analyze record versions.

  • callback (function) – Function to call back with each output line. Function must accept only one parameter: line of output.

If callback is not specified, statistical report could be retrieved through readline(), readlines(), iteration over Connection or ignored via call to wait().

Note

Until report is not fully fetched from service (or ignored via wait()), any attempt to start another asynchronous service will fail with exception.

get_users(user_name=None)

Get information about user(s).

Parameters:

user_name (string) – (Optional) When specified, returns information only about user with specified user name.

Returns list:

User instances.

isrunning()

Returns True if service is running.

Note

Some services like backup() or sweep() may take time to complete, so they’re called asynchronously. Until they’re finished, no other async service could be started.

modify_user(user)

Modify user information.

Parameters:

user (User) – Instance of User with at least its name attribute specified as non-empty value.

Note

This method sets first_name, middle_name and last_name to their actual values, and ignores the user_id and group_id attributes regardless of their values. password is set only when it has value.

next()

Return the next result line from service manager. Part of iterator protocol.

Raises:

StopIteration – If there are no further lines.

readline()

Get next line of textual output from last service query.

Returns string:

Output line.

readlines()

Get list of remaining output lines from last service query.

Returns list:

Service output.

Raises:

ProgrammingError – When service is not in fetching mode.

remove_user(user)

Remove user.

Parameters:

user (string or User) – User name or Instance of User with at least its name attribute specified as non-empty value.

repair(database, read_only_validation=0, ignore_checksums=0, kill_unavailable_shadows=0, mend_database=0, validate_database=1, validate_record_fragments=1)

Database Validation and Repair.

Parameters:
  • database (string) – Database filename or alias.

  • read_only_validation (integer) – 1 to prevent any database changes.

  • ignore_checksums (integer) – 1 to ignore page checksum errors.

  • kill_unavailable_shadows (integer) – 1 to kill unavailable shadows.

  • mend_database (integer) – 1 to fix database for backup.

  • validate_database (integer) – 0 to skip database validation.

  • validate_record_fragments (integer) – 0 to skip validation of record fragments.

Note

Method call will not return until action is finished.

restore(source_filenames, dest_filenames, dest_file_pages=(), page_size=None, cache_buffers=None, access_mode_read_only=0, replace=0, deactivate_indexes=0, do_not_restore_shadows=0, do_not_enforce_constraints=0, commit_after_each_table=0, use_all_page_space=0, no_db_triggers=0, metadata_only=0, callback=None, sep_password=None, decrypt_password=None)

Request database restore from logical (GBAK) backup. (ASYNC service)

Parameters:
  • source_filenames (string or tuple of strings) – Backup file(s) specification.

  • dest_filenames (string or tuple of strings) – Database file(s) specification.

  • dest_file_pages (tuple of integers) – (optional) specification of database file max. # of pages.

  • page_size (integer) – (optional) Page size.

  • cache_buffers (integer) – (optional) Size of page-cache for this database.

  • access_mode_read_only (integer) – 1 to create R/O database.

  • replace (integer) – 1 to replace existing database.

  • deactivate_indexes (integer) – 1 to do not activate indices.

  • do_not_restore_shadows (integer) – 1 to do not restore shadows.

  • do_not_enforce_constraints (integer) – 1 to do not enforce constraints during restore.

  • commit_after_each_table (integer) – 1 to commit after each table is restored.

  • use_all_page_space (integer) – 1 to use all space on data pages.

  • no_db_triggers (integer) – 1 to disable database triggers temporarily.

  • metadata_only (integer) – 1 to restore only database metadata.

  • callback (function) – Function to call back with each output line. Function must accept only one parameter: line of output.

If callback is not specified, restore log could be retrieved through readline(), readlines(), iteration over Connection or ignored via call to wait().

Note

Until restore report is not fully fetched from service (or ignored via wait()), any attempt to start another asynchronous service will fail with exception.

restore_tablespace(source_filenames, dest_filenames, tablespace_name, bkp_file, dest_file_pages=(), create_tablespace=0, replace_tablespace=0, callback=None)

Restore tablespace from single file :param source_filenames: Backup file(s) specification. :type source_filenames: string or tuple of strings :param dest_filenames: Database file(s) specification. :type dest_filenames: string or tuple of strings :param dest_file_pages: (optional) specification of database file max. # of pages. :type dest_file_pages: tuple of integers :param string tablespace_name: Tablespace name :param string bkp_file: Tablespace backup file :param int create_tablespace: The -create_tablespace does not raise an error if the tablespace file already exists and does not delete an existing tablespace file :param int replace_tablespace: If the existing tablespace files are corrupt the TRUNCATE TABLE command cannot be performed then it may be necessary to delete the existing files and create new files by using the -replace_tablespace switch.

rollback_limbo_transaction(database, transaction_id)

Resolve limbo transaction with rollback.

Parameters:
  • database (string) – Database filename or alias.

  • transaction_id (integer) – ID of Transaction to resolve.

set_access_mode(database, mode)

Set Database Access mode: Read Only or Read/Write

Parameters:
set_default_page_buffers(database, n)

Set individual page cache size for Database.

Parameters:
  • database (string) – Database filename or alias.

  • n (integer) – Number of pages.

set_reserve_page_space(database, reserve_space)

Set data page space reservation policy.

Parameters:
  • database (string) – Database filename or alias.

  • reserve_space (boolean) – True to reserve space, False to do not.

set_sql_dialect(database, dialect)

Set SQL Dialect for Database.

Parameters:
  • database (string) – Database filename or alias.

  • dialect (integer) – 1 or 3.

set_sweep_interval(database, n)

Set threshold for automatic sweep.

Parameters:
  • database (string) – Database filename or alias.

  • n (integer) – Sweep threshold, or 0 to disable automatic sweep.

set_write_mode(database, mode)

Set Disk Write Mode: Sync (forced writes) or Async (buffered).

Parameters:
  • database (string) – Database filename or alias.

  • mode (integer) – One from following constants: WRITE_FORCED or WRITE_BUFFERED

shutdown(database, shutdown_mode, shutdown_method, timeout)

Database shutdown.

Parameters:

See also

See also bring_online() method.

sweep(database)

Perform Database Sweep.

Note

Method call will not return until sweep is finished.

Parameters:

database (string) – Database filename or alias.

user_exists(user)

Check for user’s existence.

Parameters:

user (string or User) – User name or Instance of User with at least its name attribute specified as non-empty value.

Returns boolean:

True when the specified user exists.

wait()

Wait until running service completes.

QUERY_TYPE_PLAIN_INTEGER = 1
QUERY_TYPE_PLAIN_STRING = 2
QUERY_TYPE_RAW = 3
property closed

(Read Only) True if connection is closed.

property engine_version

(Read Only) (float) InterBase version number of connected server. Only major.minor version.

property fetching

(Read Only) True if connection is fetching result.

property version

(Read Only) (string) InterBase version number string of connected server. Uses InterBase version numbers in form: major.minor.subrelease.build

User

class interbase.services.User(name=None)
load_information(svc)

Load information about user from server.

Parameters:

svc (Connection) – Open service connection.

Returns:

True if information was successfully retrieved, False otherwise.

Raises:

ProgrammingError – If user name is not defined.

first_name

First name.

group_id

User group ID

last_name

Last name

middle_name

Middle name

name

User login name (username).

password

Password. Not returned by user output methods, but must be specified to add a user.

user_id

User ID

Database schema

Functions

interbase.schema.get_grants(privileges, grantors=None)

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

Parameters:
  • privileges (list) – List of Privilege instances.

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

interbase.schema.isKeyword(ident)

Returns True if ident is InterBase keyword.

Schema

class interbase.schema.Schema

This class represents database schema.

accept_visitor(visitor)

Visitor Pattern support. Calls visitSchema(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

bind(connection)

Bind this instance to specified Connection.

Parameters:

connectionConnection instance.

Raises:

ProgrammingError – If Schema object was set as internal (via _set_as_internal()).

clear()

Drop all cached metadata objects.

close()

Sever link to Connection.

Raises:

ProgrammingError – If Schema object was set as internal (via _set_as_internal()).

get_character_set(name)

Get CharacterSet by name.

Parameters:

name (string) – Character set name.

Returns:

CharacterSet with specified name or None.

get_character_set_by_id(id)

Get CharacterSet by ID.

Parameters:

name (integer) – CharacterSet ID.

Returns:

CharacterSet with specified ID or None.

get_collation(name)

Get Collation by name.

Parameters:

name (string) – Collation name.

Returns:

Collation with specified name or None.

get_collation_by_id(charset_id, collation_id)

Get Collation by ID.

Parameters:
  • charset_id (integer) – Character set ID.

  • collation_id (integer) – Collation ID.

Returns:

Collation with specified ID or None.

get_constraint(name)

Get Constraint by name.

Parameters:

name (string) – Constraint name.

Returns:

Constraint with specified name or None.

get_domain(name)

Get Domain by name.

Parameters:

name (string) – Domain name.

Returns:

Domain with specified name or None.

get_exception(name)

Get DatabaseException by name.

Parameters:

name (string) – Exception name.

Returns:

DatabaseException with specified name or None.

get_function(name)

Get Function by name.

Parameters:

name (string) – Function name.

Returns:

Function with specified name or None.

get_generator(name)

Get Sequence by name.

Parameters:

name (string) – Sequence name.

Returns:

Sequence with specified name or None.

get_index(name)

Get Index by name.

Parameters:

name (string) – Index name.

Returns:

Index with specified name or None.

get_privileges_of(user, user_type=None)

Get list of all privileges granted to user/database object.

Parameters:
Returns:

List of Privilege objects.

Raises:

ProgrammingError – For unknown user_type code.

get_procedure(name)

Get Procedure by name.

Parameters:

name (string) – Procedure name.

Returns:

Procedure with specified name or None.

get_role(name)

Get Role by name.

Parameters:

name (string) – Role name.

Returns:

Role with specified name or None.

get_sequence(name)

Get Sequence by name.

Parameters:

name (string) – Sequence name.

Returns:

Sequence with specified name or None.

get_table(name)

Get Table by name.

Parameters:

name (string) – Table name.

Returns:

Table with specified name or None.

get_trigger(name)

Get Trigger by name.

Parameters:

name (string) – Trigger name.

Returns:

Trigger with specified name or None.

get_view(name)

Get View by name.

Parameters:

name (string) – View name.

Returns:

View with specified name or None.

ismultifile()

Returns true if database has multiple files.

reload(data=None)

Drop all or specified category of cached metadata objects, so they’re reloaded from database on next reference.

Parameters:

data (string) – None or name of metadata category.

Recognized (case insensitive) names of metadata categories:

  • tables

  • views

  • domain

  • indices

  • dependencies

  • generators

  • sequences

  • triggers

  • procedures

  • constraints

  • collations

  • character sets

  • exceptions

  • roles

  • functions

  • files

  • shadows

  • privileges

  • users

Raises:

ProgrammingError – For undefined metadata category.

Note

Also commits query transaction.

property character_sets

List of all character sets in database. Items are CharacterSet objects.

property closed

True if link to Connection is closed.

property collations

List of all collations in database. Items are Collation objects.

property constraints

List of all constraints in database. Items are Constraint objects.

property default_character_set

Default CharacterSet for database

property dependencies

List of all dependencies in database. Items are Dependency objects.

property description

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

property domains

List of all user domains in database. Items are Domain objects.

enum_character_set_names = {}

Character set names: key = numID, value = charset_name

enum_field_subtypes = {}

Field sub types: key = numID, value = type_name

enum_field_types = {}

Field types: key = numID, value = type_name

enum_function_types = {}

Function types: key = numID, value = type_name

enum_mechanism_types = {}

Mechanism Types: key = numID, value = type_name

enum_object_type_codes = {}

Object type codes: key = type_name, value = numID

enum_object_types = {}

Object types: key = numID, value = type_name

enum_param_type_from = {0: 'DATATYPE', 1: 'DOMAIN', 2: 'TYPE OF DOMAIN', 3: 'TYPE OF COLUMN'}

Datatype declaration methods for procedure parameters: key = numID, value = name

enum_parameter_mechanism_types = {}

Parameter Mechanism Types: key = numID, value = type_name

enum_procedure_types = {}

Procedure Types: key = numID, value = type_name

enum_relation_types = {}

Relation Types: key = numID, value = type_name

enum_system_flag_types = {}

System Flag Types: key = numID, value = type_name

enum_transaction_state_types = {}

Transaction State Types: key = numID, value = type_name

enum_trigger_types = {}

Trigger Types: key = numID, value = type_name

property exceptions

List of all exceptions in database. Items are DatabaseException objects.

property files

List of all extension files defined for database. Items are DatabaseFile objects.

property functions

List of all user functions defined in database. Items are Function objects.

property generators

List of all user generators in database. Items are Sequence objects.

property indices

List of all user indices in database. Items are Index objects.

opt_always_quote = False

option switch: Always quote db object names on output

property owner_name

Database owner name.

property privileges

List of all privileges defined for database. Items are Privilege objects.

property procedures

List of all user procedures in database. Items are Procedure objects.

property roles

List of all roles in database. Items are Role objects.

property security_class

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

property sequences

List of all user generators in database. Items are Sequence objects.

property shadows

List of all shadows defined for database. Items are Shadow objects.

property sysdomains

List of all system domains in database. Items are Domain objects.

property sysfunctions

List of all system functions defined in database. Items are Function objects.

property sysgenerators

List of all system generators in database. Items are Sequence objects.

property sysindices

List of all system indices in database. Items are Index objects.

property sysprocedures

List of all system procedures in database. Items are Procedure objects.

property syssequences

List of all system generators in database. Items are Sequence objects.

property systables

List of all system tables in database. Items are Table objects.

property systriggers

List of all system triggers in database. Items are Trigger objects.

property sysviews

List of all system views in database. Items are View objects.

property tables

List of all user tables in database. Items are Table objects.

property triggers

List of all user triggers in database. Items are Trigger objects.

property views

List of all user views in database. Items are View objects.

BaseSchemaItem

class interbase.schema.BaseSchemaItem(schema, attributes)

Base class for all database schema objects.

accept_visitor(visitor)

Visitor Pattern support. Calls visitMetadatItem(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property description

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

property name

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

schema = None

Weak reference to parent Schema instance.

Collation

class interbase.schema.Collation(schema, attributes)

Represents collation.

Supported SQL actions:

  • User collation: create, drop

  • System collation: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitCollation(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

isaccentinsensitive()

Returns True if collation has ACCENT INSENSITIVE attribute.

isbasedonexternal()

Returns True if collation is based on external collation definition.

iscaseinsensitive()

Returns True if collation has CASE INSENSITIVE attribute.

ispadded()

Returns True if collation has PAD SPACE attribute.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property attributes
property character_set

Character set object associated with collation.

property description

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

property function_name

Not currently used.

property id

Collation ID.

property name

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

schema = None

Weak reference to parent Schema instance.

property specific_attributes

Collation specific attributes.

CharacterSet

class interbase.schema.CharacterSet(schema, attributes)

Represents character set.

Supported SQL actions: alter(collation=Collation instance or collation name)

accept_visitor(visitor)

Visitor Pattern support. Calls visitCharacterSet(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_collation(name)

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

get_collation_by_id(id)

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

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property bytes_per_character

Size of characters in bytes.

property collations

List of Collations associated with character set.

property default_collate

Collate object of default collate.

property description

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

property id

Character set ID.

property name

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

schema = None

Weak reference to parent Schema instance.

DatabaseException

class interbase.schema.DatabaseException(schema, attributes)

Represents database exception.

Supported SQL actions:

  • User exception: create, recreate, alter(message=string), create_or_alter, drop

  • System exception: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitException(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property description

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

property id

System-assigned unique exception number.

property message

Custom message text.

property name

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

schema = None

Weak reference to parent Schema instance.

Index

class interbase.schema.Index(schema, attributes)

Represents database index.

Supported SQL actions:

  • User index: create, activate, deactivate, recompute, drop

  • System index: recompute

accept_visitor(visitor)

Visitor Pattern support. Calls visitIndex(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

isenforcer()

Returns True if index is used to enforce a constraint.

isexpression()

Returns True if index is expression index.

isinactive()

Returns True if index is INACTIVE.

issystemobject()

Returns True if this database object is system object.

isunique()

Returns True if index is UNIQUE.

property actions

List of supported SQL operations on metadata object instance.

property constraint

Constraint instance that uses this index or None.

property description

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

property expression

Source of an expression or None.

property id

Internal number ID of the index.

property index_type

ASCENDING or DESCENDING.

property name

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

property partner_index

Associated unique/primary key Index instance, or None.

schema = None

Weak reference to parent Schema instance.

property segment_names

List of index segment names.

property segment_statistics

List of index segment statistics (for ODS 11.1 and higher).

property segments

List of index segments as TableColumn instances.

property statistics

Latest selectivity of the index.

property table

The Table instance the index applies to.

TableColumn

class interbase.schema.TableColumn(schema, table, attributes)

Represents table column.

Supported SQL actions:

  • User column: alter(name=string,datatype=string_SQLTypeDef,position=number,

    expression=computed_by_expr), drop

  • System column: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitTableColumn(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_computedby()

Returns (string) expression for column computation or None.

get_dependencies()

Return list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

has_default()

Returns True if column has default value.

iscomputed()

Returns True if column is computed.

isdomainbased()

Returns True if column is based on user domain.

isnullable()

Returns True if column can accept NULL values.

issystemobject()

Returns True if this database object is system object.

iswritable()

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

property actions

List of supported SQL operations on metadata object instance.

property collation

Collation object or None.

property datatype

Complete SQL datatype definition.

property default

Default value for column or None.

property description

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

property domain

Domain object this column is based on.

property name

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

property position

Column’s sequence number in row.

property privileges

List of Privilege objects granted to this object.

schema = None

Weak reference to parent Schema instance.

property security_class

Security class name or None.

property table

The Table object this column belongs to.

ViewColumn

class interbase.schema.ViewColumn(schema, view, attributes)

Represents view column.

Supported SQL actions: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitViewColumn(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Return list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

isnullable()

Returns True if column is NULLABLE.

issystemobject()

Returns True if this database object is system object.

iswritable()

Returns True if column is writable.

property actions

List of supported SQL operations on metadata object instance.

property base_field

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

property collation

Collation object or None.

property datatype

Complete SQL datatype definition.

property description

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

property domain

Domain object this column is based on.

property name

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

property position

Column’s sequence number in row.

property privileges

List of Privilege objects granted to this object.

schema = None

Weak reference to parent Schema instance.

property security_class

Security class name or None.

property view

View object this column belongs to.

Domain

class interbase.schema.Domain(schema, attributes)

Represents SQL Domain.

Supported SQL actions:

  • User domain: create, alter(name=string,default=string_definition_or_None, check=string_definition_or_None,datatype=string_SQLTypeDef), drop

  • System domain: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitDomain(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

has_default()

Returns True if domain has default value.

isarray()

Returns True if domain defines an array.

iscomputed()

Returns True if domain is computed.

isnullable()

Returns True if domain is not defined with NOT NULL.

issystemobject()

Return True if this database object is system object.

isvalidated()

Returns True if domain has validation constraint.

property actions

List of supported SQL operations on metadata object instance.

property character_length

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

property character_set

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

property collation

Collation object for a character column or None.

property datatype

Complete SQL datatype definition.

property default

Expression that defines the default value or None.

property description

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

property dimensions

List of dimension definition pairs if column is an array type. Always empty for non-array columns.

property expression

Expression that defines the COMPUTED BY column or None.

property external_length

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

property external_scale

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

property external_type

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

property field_type

Number code of the data type defined for the column.

property length

Length of the column in bytes.

property name

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

property precision

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

property scale

Negative number representing the scale of NUMBER and DECIMAL column.

schema = None

Weak reference to parent Schema instance.

property segment_length

For BLOB columns, a suggested length for BLOB buffers.

property sub_type

BLOB subtype.

property validation

CHECK constraint for the domain or None.

Dependency

class interbase.schema.Dependency(schema, attributes)

Maps dependency between database objects.

Supported SQL actions: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitDependency(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns empty list because Dependency object never has dependencies.

get_dependents()

Returns empty list because Dependency object never has dependents.

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

issystemobject()

Returns True as dependency entries are considered as system objects.

property actions

List of supported SQL operations on metadata object instance.

property depended_on

Database object on which dependent depends.

property depended_on_name

Name of db object on which dependent depends.

property depended_on_type

Type of db object on which dependent depends.

property dependent

Dependent database object.

property dependent_name

Dependent database object name.

property dependent_type

Dependent database object type.

property description

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

property field_name

Name of one column in depended on object.

property name

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

schema = None

Weak reference to parent Schema instance.

Constraint

class interbase.schema.Constraint(schema, attributes)

Represents table or column constraint.

Supported SQL actions:

  • Constraint on user table except NOT NULL constraint: create, drop

  • Constraint on system table: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitConstraint(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

ischeck()

Returns True if it’s CHECK constraint.

isdeferrable()

Returns True if it’s DEFERRABLE constraint.

isdeferred()

Returns True if it’s INITIALLY DEFERRED constraint.

isfkey()

Returns True if it’s FOREIGN KEY constraint.

isnotnull()

Returns True if it’s NOT NULL constraint.

ispkey()

Returns True if it’s PRIMARY KEY constraint.

issystemobject()

Returns True if this database object is system object.

isunique()

Returns True if it’s UNIQUE constraint.

property actions

List of supported SQL operations on metadata object instance.

property column_name

For a NOT NULL constraint, this is the name of the column to which the constraint applies.

property constraint_type

primary key/unique/foreign key/check/not null.

property delete_rule

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

property description

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

property index

Index instance that enforces the constraint. None if constraint is not primary key/unique or foreign key.

property match_option

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

property name

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

property partner_constraint

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

schema = None

Weak reference to parent Schema instance.

property table

Table instance this constraint applies to.

property trigger_names

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

property triggers

For a CHECK constraint contains Trigger instances that enforce the constraint.

property update_rule

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

Table

class interbase.schema.Table(schema, attributes)

Represents Table in database.

Supported SQL actions:

  • User table: create, recreate, drop

  • System table: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitTable(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_column(name)

Return TableColumn object with specified name.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

has_fkey()

Returns True if table has any FOREIGN KEY constraint.

has_pkey()

Returns True if table has PRIMARY KEY defined.

isexternal()

Returns True if table is external table.

isgtt()

Returns True if table is GLOBAL TEMPORARY table.

ispersistent()

Returns True if table is persistent one.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property columns

Returns list of columns defined for table. Items are TableColumn objects.

property constraints

Returns list of constraints defined for table. Items are Constraint objects.

property dbkey_length

Length of the RDB$DB_KEY column in bytes.

property default_class

Default security class.

property description

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

property external_file

Full path to the external data file, if any.

property flags

Internal flags.

property foreign_keys

List of FOREIGN KEY Constraint instances for this table.

property format

Internal format ID for the table.

property id

Internam number ID for the table.

property indices

Returns list of indices defined for table. Items are Index objects.

property name

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

property owner_name

User name of table’s creator.

property primary_key

PRIMARY KEY Constraint for this table or None.

property privileges

List of Privilege objects granted to this object.

schema = None

Weak reference to parent Schema instance.

property security_class

Security class that define access limits to the table.

property table_type

Table type.

property triggers

Returns list of triggers defined for table. Items are Trigger objects.

View

class interbase.schema.View(schema, attributes)

Represents database View.

Supported SQL actions:

  • User views: create, recreate, alter(columns=string_or_list,query=string,check=bool), create_or_alter, drop

  • System views: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitView(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_column(name)

Return TableColumn object with specified name.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

get_trigger(name)

Return Trigger object with specified name.

has_checkoption()

Returns True if View has WITH CHECK OPTION defined.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property columns

Returns list of columns defined for view. Items are ViewColumn objects.

property dbkey_length

Length of the RDB$DB_KEY column in bytes.

property default_class

Default security class.

property description

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

property flags

Internal flags.

property format

Internal format ID for the view.

property id

Internal number ID for the view.

property name

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

property owner_name

User name of view’s creator.

property privileges

List of Privilege objects granted to this object.

schema = None

Weak reference to parent Schema instance.

property security_class

Security class that define access limits to the view.

property sql

The query specification.

property triggers

Returns list of triggers defined for view. Items are Trigger objects.

Trigger

class interbase.schema.Trigger(schema, attributes)

Represents trigger.

Supported SQL actions:

  • User trigger: create, recreate, create_or_alter, drop, alter(fire_on=string,active=bool,sequence=int,declare=string_or_list, code=string_or_list)

  • System trigger: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitTrigger(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

get_type_as_string()

Return string with action and operation specification.

isactive()

Returns True if this trigger is active.

isafter()

Returns True if this trigger is set for AFTER action.

isbefore()

Returns True if this trigger is set for BEFORE action.

isdbtrigger()

Returns True if this trigger is database trigger.

isdelete()

Returns True if this trigger is set for DELETE operation.

isinsert()

Returns True if this trigger is set for INSERT operation.

issystemobject()

Returns True if this database object is system object.

isupdate()

Returns True if this trigger is set for UPDATE operation.

property actions

List of supported SQL operations on metadata object instance.

property description

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

property flags

Internal flags.

property name

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

property relation

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

schema = None

Weak reference to parent Schema instance.

property sequence

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

property source

PSQL source code.

property trigger_type

Numeric code for trigger type that define what event and when are covered by trigger.

ProcedureParameter

class interbase.schema.ProcedureParameter(schema, proc, attributes)

Represents procedure parameter.

Supported SQL actions: none.

accept_visitor(visitor)

Visitor Pattern support. Calls visitProcedureParameter(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_definition()

Returns SQL definition for parameter.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

has_default()

Returns True if parameter has default value.

isinput()

Returns True if parameter is INPUT parameter.

isnullable()

Returns True if parameter allows NULL.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property collation

collation for this parameter.

property column

TableColumn for this parameter.

property datatype

Complete SQL datatype definition.

property default

Default value.

property description

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

property domain

Domain for this parameter.

property mechanism

Parameter mechanism code.

property name

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

property procedure

Name of the stored procedure.

schema = None

Weak reference to parent Schema instance.

property sequence

Sequence (position) of parameter.

property type_from

Numeric code. See Schema.enum_param_type_from.`

Procedure

class interbase.schema.Procedure(schema, attributes)

Represents stored procedure.

Supported SQL actions:

  • User procedure: create(no_code=bool), recreate(no_code=bool), create_or_alter(no_code=bool), drop, alter(input=string_or_list,output=string_or_list,declare=string_or_list, code=string_or_list)

  • System procedure: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitProcedure(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_param(name)

Returns ProcedureParameter with specified name or None

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

has_input()

Returns True if procedure has any input parameters.

has_output()

Returns True if procedure has any output parameters.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property description

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

property id

Internal unique ID number.

property input_params

List of input parameters. Instances are ProcedureParameter instances.

property name

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

property output_params

List of output parameters. Instances are ProcedureParameter instances.

property owner_name

User name of procedure’s creator.

property privileges

List of Privilege objects granted to this object.

property proc_type

Procedure type code. See interbase.Connection.enum_procedure_types.

schema = None

Weak reference to parent Schema instance.

property security_class

Security class that define access limits to the procedure.

property source

PSQL source code.

property valid_blr

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

Role

class interbase.schema.Role(schema, attributes)

Represents user role.

Supported SQL actions:

  • User role: create, drop

  • System role: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitRole(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property description

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

property name

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

property owner_name

User name of role owner.

property privileges

List of Privilege objects granted to this object.

schema = None

Weak reference to parent Schema instance.

FunctionArgument

class interbase.schema.FunctionArgument(schema, function, attributes)

Represets UDF argument.

Supported SQL actions: none.

accept_visitor(visitor)

Visitor Pattern support. Calls visitFunctionArgument(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_definition()

Returns SQL definition for parameter.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

isbydescriptor(any=False)

Returns True if argument is passed by descriptor.

Parameters:

any (bool) – If True, method returns True if any kind of descriptor is used (including BLOB and ARRAY descriptors).

isbyreference()

Returns True if argument is passed by reference.

isbyvalue()

Returns True if argument is passed by value.

isfreeit()

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

isreturning()

Returns True if argument represents return value for function.

issystemobject()

Returns True if this database object is system object.

iswithnull()

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

property actions

List of supported SQL operations on metadata object instance.

property character_length

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

property character_set

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

property datatype

Complete SQL datatype definition.

property description

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

property field_type

Number code of the data type defined for the argument.

property function

Function to which this argument belongs.

property length

Length of the argument in bytes.

property mechanism

How argument is passed.

property name

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

property position

Argument position.

property precision

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

property scale

Negative number representing the scale of NUMBER and DECIMAL argument.

schema = None

Weak reference to parent Schema instance.

property sub_type

BLOB subtype.

Function

class interbase.schema.Function(schema, attributes)

Represents user defined function.

Supported SQL actions:

  • User UDF: declare, drop

  • System UDF: none

accept_visitor(visitor)

Visitor Pattern support. Calls visitFunction(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

has_arguments()

Returns True if function has input arguments.

has_return()

Returns True if function returns a value.

has_return_argument()

Returns True if function returns a value in input argument.

issystemobject()

Returns True if this database object is system object.

property actions

List of supported SQL operations on metadata object instance.

property arguments

List of function arguments. Items are FunctionArgument instances.

property description

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

property entrypoint

Entrypoint in module.

property module_name

Module name.

property name

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

property returns

Returning FunctionArgument or None.

schema = None

Weak reference to parent Schema instance.

DatabaseFile

class interbase.schema.DatabaseFile(schema, attributes)

Represents database extension file.

Supported SQL actions: create

accept_visitor(visitor)

Visitor Pattern support. Calls visitDatabaseFile(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

issystemobject()

Returns True.

property actions

List of supported SQL operations on metadata object instance.

property description

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

property filename

File name.

property length

File length in pages.

property name

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

schema = None

Weak reference to parent Schema instance.

property sequence

File sequence number.

property start

File start page number.

Shadow

class interbase.schema.Shadow(schema, attributes)

Represents database shadow.

Supported SQL actions: create, drop

accept_visitor(visitor)

Visitor Pattern support. Calls visitShadow(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

isconditional()

Returns True if it’s CONDITIONAL shadow.

isinactive()

Returns True if it’s INACTIVE shadow.

ismanual()

Returns True if it’s MANUAL shadow.

issystemobject()

Returns False.

SHADOW_CONDITIONAL = 16
SHADOW_INACTIVE = 2
SHADOW_MANUAL = 4
property actions

List of supported SQL operations on metadata object instance.

property description

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

property files

List of shadow files. Items are DatabaseFile instances.

property flags

Shadow flags.

property id

Shadow ID number.

property name

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

schema = None

Weak reference to parent Schema instance.

Privilege

class interbase.schema.Privilege(schema, attributes)

Represents privilege to database object.

Supported SQL actions: grant(grantors),revoke(grantors,grant_option)

accept_visitor(visitor)

Visitor Pattern support. Calls visitPrivilege(self) on parameter object.

Parameters:

visitor – Visitor object of Visitor Pattern.

get_dependencies()

Returns list of database objects that this object depend on.

get_dependents()

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

get_quoted_name()

Returns quoted (if necessary) name.

get_sql_for(action, **params)

Returns SQL command for specified action on metadata object.

Supported actions are defined by actions list.

Raises:

ProgrammingError – For unsupported action or wrong parameters passed.

has_grant()

Returns True if privilege comes with GRANT OPTION.

isdelete()

Returns True if this is DELETE privilege.

isexecute()

Returns True if this is EXECUTE privilege.

isinsert()

Returns True if this is INSERT privilege.

ismembership()

Returns True if this is ROLE membership privilege.

isreference()

Returns True if this is REFERENCE privilege.

isselect()

Returns True if this is SELECT privilege.

issystemobject()

Returns True.

isupdate()

Returns True if this is UPDATE privilege.

property actions

List of supported SQL operations on metadata object instance.

property description

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

property field_name

Field name.

property grantor

Grantor User object.

property grantor_name

Grantor name.

property name

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

property privilege

Privilege code.

schema = None

Weak reference to parent Schema instance.

property subject

Privilege subject. Either Role, Table, View or Procedure object.

property subject_name

Subject name.

property subject_type

Subject type.

property user

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

property user_name

User name.

property user_type

User type.

SchemaVisitor

class interbase.schema.SchemaVisitor

Helper class for implementation of schema Visitor.

Implements all visit* methods supported by schema classes as calls to default_action().

default_action(obj)

Does nothing.

visitCharacterSet(character_set)
visitCollation(collation)
visitConstraint(constraint)
visitDatabaseFile(dbfile)
visitDependency(dependency)
visitDomain(domain)
visitException(exception)
visitFunction(function)
visitFunctionArgument(arg)
visitGenerator(generator)
visitIndex(index)
visitMetadataItem(item)
visitProcedure(procedure)
visitProcedureParameter(param)
visitRole(role)
visitSchema(schema)
visitShadow(shadow)
visitTable(table)
visitTableColumn(column)
visitTrigger(trigger)
visitView(view)
visitViewColumn(column)

Utilities

Functions

interbase.utils.update_meta(self, other)

Helper function for LateBindingProperty class.

interbase.utils.iter_class_properties(cls)

Iterator that yields name, property pairs for all properties in class.

Parameters:

cls (class) – Class object.

interbase.utils.iter_class_variables(cls)

Iterator that yields names of all non-callable attributes in class.

Parameters:

cls (class) – Class object.

interbase.utils.embed_attributes(from_class, attr)

Class decorator that injects properties and non-callable attributes from another class instance embedded in class instances.

param class from_class:

Class that should extend decorated class.

param string attr:

Attribute name that holds instance of embedded class within decorated class instance.

LateBindingProperty

class interbase.utils.LateBindingProperty(fget=None, fset=None, fdel=None, doc=None)

Peroperty class that binds to getter/setter/deleter methods when instance of class that define the property is created. This allows you to override these methods in descendant classes (if they are not private) without necessity to redeclare the property itself in descendant class.

Recipe from Tim Delaney, 2005/03/31 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/408713

class C(object):

    def getx(self):
        print 'C.getx'
        return self._x

    def setx(self, x):
        print 'C.setx'
        self._x = x

    def delx(self):
        print 'C.delx'
        del self._x

    x = LateBindingProperty(getx, setx, delx)

class D(C):

    def setx(self, x):
        print 'D.setx'
        super(D, self).setx(x)

    def delx(self):
        print 'D.delx'
        super(D, self).delx()

c = C()
c.x = 1
c.x
c.x
del c.x

print

d = D()
d.x = 1
d.x
d.x
del d.x

This has the advantages that:

  1. You get back an actual property object (with attendant memory savings, performance increases, etc);

  2. It’s the same syntax as using property(fget, fset, fdel, doc) except for the name;

  3. It will fail earlier (when you define the class as opposed to when you use it).

  4. It’s shorter ;)

  5. If you inspect the property you will get back functions with the correct __name__, __doc__, etc.

Iterator

class interbase.utils.Iterator(method, sentinel=None)

Generic iterator implementation.

Parameters:
  • method – Callable without parameters that returns next item.

  • sentinel – Value that when returned by method indicates the end of sequence.

next()

EmbeddedProperty

class interbase.utils.EmbeddedProperty(obj, prop)

Property class that forwards calls to getter/setter/deleter methods to respective property methods of another object. This class allows you to “inject” properties from embedded object into class definition of parent object.

Parameters:
  • obj (string) – Attribute name with embedded object.

  • prop (property) – Property instance from embedded object.

EmbeddedAttribute

class interbase.utils.EmbeddedAttribute(obj, attr)

Property class that gets/sets attribute of another object. This class allows you to “inject” attributes from embedded object into class definition of parent object.

Parameters:
  • obj (string) – Attribute name with embedded object.

  • attr (string) – Attribute name from embedded object.

ctypes interface to InterBase client library

ctypes interface to gds.so/dylib and gds32/ibclient64.dll is defined in submodule interbase.ibase and interbase.blr.

class interbase.ibase.ibclient_API(ib_library_name=None, embedded=False)

InterBase Client API interface object. Loads InterBase Client Library and exposes API functions as member methods. Uses ctypes for bindings.