Current driver version, string.
String constant stating the supported DB API level (2.0).
Integer constant stating the level of thread safety the interface supports.
Curretly 1 = Threads may share the module, but not connections.
String constant stating the type of parameter marker formatting expected by the interface.
‘qmark’ = Question mark style, e.g. ‘...WHERE name=?’
Helper constants for work with Cursor.description content.
Bases: exceptions.Exception
Exception raised for important warnings like data truncations while inserting, etc.
Bases: exceptions.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.
Bases: fdb.fbcore.Error
Exception raised for errors that are related to the database interface rather than the database itself.
Bases: fdb.fbcore.Error
Exception raised for errors that are related to the database.
Bases: fdb.fbcore.DatabaseError
Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range, etc.
Bases: fdb.fbcore.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.
Bases: fdb.fbcore.DatabaseError
Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails.
Bases: fdb.fbcore.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.
Bases: fdb.fbcore.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.
Bases: fdb.fbcore.DatabaseError
Exception raised in case a method or database API was used which is not supported by the database
Bases: fdb.fbcore.DatabaseError
This is the exception inheritance layout:
StandardError
|__Warning
|__Error
|__InterfaceError
|__DatabaseError
|__DataError
|__OperationalError
|__IntegrityError
|__InternalError
|__ProgrammingError
|__NotSupportedError
Establish a connection to database.
Parameters: |
|
---|---|
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 = fdb.connect(dsn='host:/path/database.fdb', user='sysdba', password='pass', charset='UTF8')
con = fdb.connect(host='myhost', database='/path/database.fdb', user='sysdba', password='pass', charset='UTF8')
Creates a new database with the supplied “CREATE DATABASE” statement.
Parameters: |
|
---|---|
Returns: | Connection to the newly created database. |
Return type: | Connection instance. |
Raises ProgrammingError: | |
When database creation fails. |
Example:
con = fdb.create_database("create database '/temp/db.db' user 'sysdba' password 'pass'")
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: |
|
---|
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 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 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. |
Return a new Cursor instance using the connection associated with main_transaction. See Transaction.cursor() for details.
Raises ProgrammingError: | |
---|---|
If Connection is closed. |
Wraps the Firebird 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 FB 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: |
|
---|---|
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 fdb.services).
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 fdb.isc_info_* info request code or a sequence of such codes. |
---|---|
Returns: | Mapping of (info request code -> result). |
Raises: |
|
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: |
|
---|
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. |
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: |
|
Causes the the database to roll back to the start of pending transaction. Operates on main_transaction. See Transaction.rollback() for details.
Parameters: |
|
---|---|
Raises ProgrammingError: | |
If Connection is closed. |
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')
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. |
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: |
|
Returns information about active transaction. Thin wrapper around Firebird API isc_transaction_info call. Operates on main_transaction. See Transaction.transaction_info() for details.
Parameters: |
|
---|---|
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: |
|
(Read Only) (string) Connection Character set name.
(Read Only) True if connection is closed.
(Read/Write) Deafult Transaction Parameter Block used for all newly started transactions.
(Read Only) ConnectionGroup this Connection belongs to, or None.
(Read Only) Main Transaction instance for this connection Connection methods begin(), savepoint(), commit() and rollback() are delegated to this transaction object.
(Read Only) (string) Version string returned by server for this connection.
(integer) sql_dialect for this connection, do not change.
(Read Only) (tuple) Transaction instances associated with this connection.
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. Cursor has an internal cache of PreparedStatements, so when the same SQL statement is executed repeatedly, related PreparedStatement is re-used, which enhances performance. This convenient enhancement has a side effect: Cursor that was used to perform many different SQL statements may hold very large cache of PerapedStatements. To clear the cache, you’ll need to call clear_cache().
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: |
|
---|
Call a stored database procedure with the given name.
The result of the call is available through the standard fetchXXX() methods.
Parameters: |
|
---|---|
Returns: | parameters, as required by Python DB API 2.0 Spec. |
Raises: |
|
Clear the internal cache with PreparedStatement instances.
All prepared statements except current one are permanently closed, and the cache is cleared.
Note
Current prepared statement is still in its actual state, but it’s removed from cache, so when next statement (even the same SQL command) is executed, this current PreparedStatement instance is disposed.
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
FDB’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.
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: |
|
Raises: |
|
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.
Parameters: |
|
---|---|
Raises: |
|
Fetch all (remaining) rows of a query result.
Returns: | List of tuples, where each tuple is one row of returned values. |
---|---|
Raises: |
|
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 fbcore._RowMapping instances, one such instance for each row. |
---|---|
Raises: |
|
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: |
|
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 fbcore._RowMapping instances, one such instance for each row. |
Raises: |
|
Fetch the next row of a query result set.
Returns: | tuple of returned values, or None when no more data is available. |
---|---|
Raises: |
|
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: | fbcore._RowMapping of returned values, or None when no more data is available. |
---|---|
Raises: |
|
Equivalent to the fetchall(), except that it returns iterator rather than materialized list.
Returns: | Iterator that yields tuple of values like fetchone(). |
---|
Equivalent to the fetchallmap(), except that it returns iterator rather than materialized list.
Returns: | Iterator that yields fbcore._RowMapping instance like fetchonemap(). |
---|
Return the next item from the container. Part of iterator protocol.
Raises StopIteration: | |
---|---|
If there are no further items. |
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: |
|
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: | |
Required by Python DB API 2.0, but pointless for Firebird, so it does nothing.
Required by Python DB API 2.0, but pointless for Firebird, so it does nothing.
(Read/Write) As required by the Python DB API 2.0 spec, the value of this attribute is observed with respect to the fetchmany() method. However, changing the value of this attribute does not make any difference in fetch efficiency because the database engine only supports fetching a single row at a time.
(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.
(Read/Write) (string) Name for the SQL cursor. This property can be ignored entirely if you don’t need to use it.
(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.
(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.
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: |
|
---|---|
Raises ProgrammingError: | |
When zero or more than 16 connections are given. |
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: |
|
---|
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 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. |
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. |
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. |
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.
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: |
|
---|---|
Raises: |
|
Establishes a savepoint with the specified name.
Note
If transaction is bound to multiple connections, savepoint is created on all of them.
Important
Because savepoint is created not through Firebird API (there is no such API call), but by executing SAVEPOINT <name> SQL statement, calling this method starts the transaction if it was not yet started.
Parameters: | name (string) – Savepoint name. |
---|
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. |
Return information about active transaction.
This is very thin wrapper around Firebird API isc_transaction_info call.
Parameters: |
|
---|---|
Raises: |
|
(Read Only) True if transaction is active.
(Read Only) True if transaction is closed.
(Read/Write) (string) ‘commit’ or ‘rollback’, action to be taken when physical transaction has to be ended automatically. Default is ‘commit’.
(Read/Write) Transaction Parameter Block. Default is ISOLATION_LEVEL_READ_COMMITED.
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.
Drops the resources associated with executed prepared statement, but keeps it prepared for another execution.
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. |
---|
Constant for internal use by this class.
Constant for internal use by this class.
(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 couldbe still used for another execution.
(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)
Internal XSQLDA structure for input values.
Internal list to save original input SQLDA structures when they has to temporarily augmented.
The number of input parameters the statement requires.
The number of output fields the statement produces.
(Read/Write) (string) Name for the SQL cursor. This property can be ignored entirely if you don’t need to use it.
Internal XSQLDA structure for output values.
(Read Only) (string) A string representation of the execution plan generated for this statement by the database engine’s optimizer.
(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.
(Read Only) (string) SQL command this PreparedStatement executes.
(integer) An integer code that can be matched against the statement type constants in the isc_info_sql_stmt_* series.
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.
Adds active connection to the group.
Parameters: | con – A Connection instance to add to this group. |
---|---|
Raises: |
|
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. |
Removes all connections from group.
Raises ProgrammingError: | |
---|---|
When transaction is active. |
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. |
Returns True if specified connection belong to this group.
Parameters: | con – Connection instance. |
---|
Returns number of Connection objects that belong to this group.
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: | connection – Connection instance. |
---|---|
Raises ProgrammingError: | |
When group is empty or specified connection doesn’t belong to this group. |
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.
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. |
Returns list of connection objects that belong to this group.
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.
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. |
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. |
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. |
(Read/Write) Deafult Transaction Parameter Block used for transactions.
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.
From the moment the conduit is created by the Connection.event_conduit() method, 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).
Parameters: |
|
---|
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.
Clear any event notifications that have accumulated in the conduit’s internal queue.
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.wait()
{
'event_a': 1,
'event_b': 0
}
In the example above event_a occurred once and event_b did not occur at all.
(Read Only) (boolean) True if conduit is closed.
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().
Closes the Reader. Like file.close().
Raises DatabaseError: | |
---|---|
When error is returned by server. |
Flush the internal buffer. Like file.flush(). Does nothing as it’s pointless for reader.
Return the next line from the BLOB. Part of iterator protocol.
Raises StopIteration: | |
---|---|
If there are no further lines. |
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.
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.
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.
Set the file’s current position, like stdio‘s fseek(). See file.seek() details.
Parameters: |
|
---|---|
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 Firebird.
Return current position in BLOB, like stdio‘s ftell() and file.tell().
(Read Only) (boolean) True is BlobReader is closed.
(Read Only) (string) File mode - always “rb”
Helper class for convenient and safe construction of custom Transaction Parameter Blocks.
Returns a copy of self.
Create valid transaction parameter block according to current values of member attributes.
Returns: | (string) TPB block. |
---|
(integer) Required access mode (isc_tpb_read or isc_tpb_write). Default: isc_tpb_write
(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
(integer) Required lock resolution method. Either isc_tpb_wait or isc_tpb_nowait.
Default: isc_tpb_wait
(integer) Required lock timeout or None.
Default: None
(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"] = (fdb.isc_tpb_protected, fdb.isc_tpb_lock_write)
A dictionary-like helper class that maps “TABLE_NAME”: (sharingMode, accessMode). It performs validation of values assigned to keys.
Create valid table access parameter block according to current key/value pairs.
Returns: | (string) Table access definition block. |
---|
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.
These constants are to be passed as the shutdown_mode parameter to Connection.shutdown()
These constants are to be passed as the shutdown_method parameter to Connection.shutdown()
These constants are to be passed as the mode parameter to Connection.setWriteMode()
These constants are to be passed as the mode parameter to Connection.setAccessMode()
These constants are return values of Connection.get_server_capabilities()
Establishes a connection to the Services Manager.
Parameters: |
|
---|
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.
Represents a sevice 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 Database Shadow(s).
Parameters: | database (string) – Database filename or alias. |
---|
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. |
---|
Request logical (GBAK) database backup. (ASYNC service)
Parameters: |
|
---|
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.
Bring previously shut down database back online.
Parameters: |
|
---|
See also
See also shutdown() method.
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.
Resolve limbo transaction with commit.
Parameters: |
|
---|
Get Firebird Server architecture.
Returns string: | Architecture (example: ‘Firebird/linux AMD64’). |
---|
Get list of attached databases.
Returns list: | Filenames of attached databases. |
---|
Get number of attachments to server.
Returns integer: | |
---|---|
Directory path. |
Get Firebird Home (installation) Directory.
Returns string: | Directory path. |
---|
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 directory location for Firebird lock files.
Returns string: | Directory path. |
---|
Request content of Firebird 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 directory with Firebird message file.
Returns string: | Directory path. |
---|
Get full path to Firebird security database.
Returns string: | Path (path+filename) to security database. |
---|
Get list of Firebird capabilities.
Returns tuple: | Capability info codes for each capability reported by server. |
---|
Next fdb.services constants define possible info codes returned:
:data:`CAPABILITY_MULTI_CLIENT`
:data:`CAPABILITY_REMOTE_HOP`
:data:`CAPABILITY_SERVER_CONFIG`
:data:`CAPABILITY_QUOTED_FILENAME`
:data:`CAPABILITY_NO_SERVER_SHUTDOWN`
Example:
>>>fdb.services.CAPABILITY_REMOTE_HOP in svc.get_server_capabilities()
True
Get Firebird version.
Returns string: | Firebird version (example: ‘LI-V2.5.2.26536 Firebird 2.5’). |
---|
Get Firebird Service Manager version number.
Returns integer: | |
---|---|
Version number. |
Request database statisctics. (ASYNC service)
Parameters: |
|
---|
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 information about user(s).
Parameters: | user_name (string) – (Optional) When specified, returns information only about user with specified user name. |
---|---|
Returns list: | User instances. |
Returns True if service is running.
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.
Perform physical (NBACKUP) database backup.
Parameters: |
|
---|
Note
Method call will not return until action is finished.
Return the next result line from service manager. Part of iterator protocol.
Raises StopIteration: | |
---|---|
If there are no further lines. |
Perform restore from physical (NBACKUP) database backup.
Parameters: |
|
---|
Note
Method call will not return until action is finished.
Get next line of textual output from last service query.
Returns string: | Output line. |
---|
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.
Parameters: | user (string or User) – User name or Instance of User with at least its name attribute specified as non-empty value. |
---|
Database Validation and Repair.
Parameters: |
|
---|
Note
Method call will not return until action is finished.
Request database restore from logical (GBAK) backup. (ASYNC service)
Parameters: |
|
---|
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.
Resolve limbo transaction with rollback.
Parameters: |
|
---|
Set Database Access mode: Read Only or Read/Write
Parameters: |
|
---|
Set individual page cache size for Database.
Parameters: |
|
---|
Set data page space reservation policy.
Parameters: |
|
---|
Set SQL Dialect for Database.
Parameters: |
|
---|
Set treshold for automatic sweep.
Parameters: |
|
---|
Set Disk Write Mode: Sync (forced writes) or Async (buffered).
Parameters: |
|
---|
Database shutdown.
Parameters: |
|
---|
See also
See also bring_online() method.
Perform Database Sweep.
Note
Method call will not return until sweep is finished.
Parameters: | database (string) – Database filename or alias. |
---|
Get information about existing trace sessions.
Returns dictionary: | |||||||||
---|---|---|---|---|---|---|---|---|---|
Mapping SESSION_ID -> SESSION_PARAMS Session parameters is another dictionary with next keys:
|
|||||||||
Raises OperationalError: | |||||||||
When server can’t perform requested operation. |
Resume trace session.
Parameters: | trace_id (integer) – Trace session ID. |
---|---|
Returns string: | Text with confirmation that session was resumed. |
Raises: |
|
Start new trace session. (ASYNC service)
Parameters: | |
---|---|
Returns integer: | |
Trace session ID. |
|
Raises DatabaseError: | |
When session ID is not returned on start. |
Trace session output could be retrieved through readline(), readlines(), iteration over Connection or ignored via call to wait().
Note
Until session output is not fully fetched from service (or ignored via wait()), any attempt to start another asynchronous service including call to any trace_ method will fail with exception.
Stop trace session.
Parameters: | trace_id (integer) – Trace session ID. |
---|---|
Returns string: | Text with confirmation that session was stopped. |
Raises: |
|
Suspend trace session.
Parameters: | trace_id (integer) – Trace session ID. |
---|---|
Returns string: | Text with confirmation that session was paused. |
Raises: |
|
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 until running service completes.
(Read Only) True if connection is closed.
(Read Only) True if connection is fetching result.
First name.
User group ID
Last name
Middle name
User login name (username).
Password. Not returned by user output methods, but must be specified to add a user.
User ID
ctypes interface to fbclient.so/dll is defined in submodule fdb.ibase.
alias of str
alias of str
alias of unicode
alias of long
alias of str
alias of int
alias of long
alias of float
alias of list
alias of unicode
alias of tuple
xrange([start,] stop[, step]) -> xrange object
Like range(), but instead of returning a list, returns an object that generates the numbers in the range on demand. For looping, this is slightly faster than range() and more memory efficient.
ord(c) -> integer
Return the integer ordinal of a one-character string.
chr(i) -> character
Return a string of one character with ordinal i; 0 <= i < 256.