firebird.driver.types¶
Exceptions¶
Next exceptions are required by Python DB API 2.0
Error is imported from firebird.base.types.
firebird.driver.types.Error
¶
Bases: Exception
Exception intended as a base for application-related errors.
Unlike the standard Exception, this class accepts arbitrary keyword arguments during initialization. These keyword arguments are stored as attributes on the exception instance.
Attribute lookup on instances of Error (or its subclasses) will return
None for any attribute that was not explicitly set via keyword arguments
during __init__, preventing AttributeError for common checks.
Important
Attribute lookup on this class never fails, as all attributes that are not actually
set, have None value. The special attribute __notes__ (used by add_note
since Python 3.11) is explicitly excluded from this behavior to ensure
compatibility.
Example
Note
Warnings are not errors and should typically derive from Warning, not this class.
- Reference firebird.driver.config
- Reference firebird.driver.types Error
- Reference firebird.driver.types
Source code in firebird/base/types.py
firebird.driver.types.InterfaceError
¶
Bases: Error
Exception raised for errors that are reported by the driver rather than the Firebird itself.
Source code in firebird/driver/types.py
firebird.driver.types.DatabaseError
¶
Bases: Error
Exception raised for all errors reported by Firebird.
Source code in firebird/driver/types.py
firebird.driver.types.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.
Note
This exception class exists for DB-API 2.0 compatibility. The driver typically raises the base DatabaseError with specific Firebird codes, rather than this specialized subclass directly.
Source code in firebird/driver/types.py
firebird.driver.types.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.
Note
This exception class exists for DB-API 2.0 compatibility. The driver typically raises the base DatabaseError with specific Firebird codes, rather than this specialized subclass directly.
Source code in firebird/driver/types.py
firebird.driver.types.IntegrityError
¶
Bases: DatabaseError
Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails.
Important
This exceptions is never directly thrown by Firebird driver.
Source code in firebird/driver/types.py
firebird.driver.types.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.
Important
This exceptions is never directly thrown by Firebird driver.
Source code in firebird/driver/types.py
firebird.driver.types.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.
Important
This exceptions is never directly thrown by Firebird driver.
Source code in firebird/driver/types.py
firebird.driver.types.NotSupportedError
¶
Bases: DatabaseError
Exception raised in case a method or database API was used which is not supported by the database.
Source code in firebird/driver/types.py
firebird.driver.types.FirebirdWarning
¶
Bases: UserWarning
Warning from Firebird engine.
The important difference from Warning class is that FirebirdWarning accepts keyword
arguments, that are stored into instance attributes with the same name.
Important
Attribute lookup on this class never fails, as all attributes that are not actually
set, have None value.
Example:
try:
if condition:
raise FirebirdWarning("Error message", err_code=1)
else:
raise FirebirdWarning("Unknown error")
except FirebirdWarning as e:
if e.err_code is None:
...
elif e.err_code == 1:
...
Source code in firebird/driver/types.py
This is the exception inheritance layout:
Exception
|__Error
|__InterfaceError
|__DatabaseError
|__DataError
|__OperationalError
|__IntegrityError
|__InternalError
|__ProgrammingError
|__NotSupportedError
UserWarning
|__FirebirdWarning
Sentinels¶
firebird.driver.types.TIMEOUT
¶
Other constants and types required by Python DB API 2.0 specification¶
Globals¶
firebird.driver.types.apilevel: str
module-attribute
¶
String constant stating the supported DB API level.
firebird.driver.types.threadsafety: int
module-attribute
¶
Integer constant stating the level of thread safety the interface supports.
Curretly 1 = Threads may share the module, but not connections.
firebird.driver.types.paramstyle: str
module-attribute
¶
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¶
- DESCRIPTION_NAME
- DESCRIPTION_TYPE_CODE
- DESCRIPTION_DISPLAY_SIZE
- DESCRIPTION_INTERNAL_SIZE
- DESCRIPTION_PRECISION
- DESCRIPTION_SCALE
- DESCRIPTION_NULL_OK
Types¶
firebird.driver.types.STRING
module-attribute
¶
This type object is used to describe columns in a database that are string-based (e.g. CHAR).
firebird.driver.types.BINARY
module-attribute
¶
This type object is used to describe (long) binary columns in a database (e.g. LONG, RAW, BLOBs).
firebird.driver.types.NUMBER
module-attribute
¶
This type object is used to describe numeric columns in a database.
firebird.driver.types.DATETIME
module-attribute
¶
This type object is used to describe date/time columns in a database.
firebird.driver.types.ROWID
module-attribute
¶
This type object is used to describe the "Row ID" column in a database.
Constructors for data types¶
firebird.driver.types.Date
module-attribute
¶
This callable constructs an object holding a date value.
firebird.driver.types.Time
module-attribute
¶
This callable constructs an object holding a time value.
firebird.driver.types.Timestamp
module-attribute
¶
This callable constructs an object holding a time stamp value.
firebird.driver.types.DateFromTicks(ticks: float) -> Date
¶
Constructs an object holding a date value from the given ticks value (number of seconds since the epoch).
firebird.driver.types.TimeFromTicks(ticks: float) -> Time
¶
Constructs an object holding a time value from the given ticks value (number of seconds since the epoch).
firebird.driver.types.TimestampFromTicks(ticks: float) -> Timestamp
¶
Constructs an object holding a time stamp value from the given ticks value (number of seconds since the epoch).
firebird.driver.types.Binary
module-attribute
¶
This callable constructs an object capable of holding a binary (long) string value.
Types for type hints¶
firebird.driver.types.DESCRIPTION
module-attribute
¶
DB API 2.0 Cursor DESCRIPTION
firebird.driver.types.CB_OUTPUT_LINE
module-attribute
¶
Callback that accepts line of text output
firebird.driver.types.Transactional
¶
Bases: Protocol
Protocol type for object that supports transactional processing.
- Reference firebird.driver.core transaction
Source code in firebird/driver/types.py
Enums¶
firebird.driver.types.NetProtocol
¶
firebird.driver.types.DirectoryCode
¶
Bases: IntEnum
IConfigManager directory codes.
Source code in firebird/driver/types.py
firebird.driver.types.XpbKind
¶
Bases: IntEnum
Xpb builder kinds.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.StateResult
¶
firebird.driver.types.PageSize
¶
Bases: IntEnum
Supported database page sizes.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.DBKeyScope
¶
Bases: IntEnum
Scope of DBKey context.
- Reference firebird.driver.core
Source code in firebird/driver/types.py
firebird.driver.types.InfoItemType
¶
firebird.driver.types.SrvInfoCode
¶
Bases: IntEnum
Service information (isc_info_svc_*) codes.
- Reference firebird.driver.core ServerInfoProvider get_info
Source code in firebird/driver/types.py
firebird.driver.types.BlobInfoCode
¶
firebird.driver.types.DbInfoCode
¶
Bases: IntEnum
Database information codes, corresponding to the isc_info_* constants used for database-level information requests.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
firebird.driver.types.ResultSetInfoCode
¶
firebird.driver.types.Features
¶
Bases: IntEnum
Firebird features (Response to DbInfoCode.FEATURES).
Source code in firebird/driver/types.py
firebird.driver.types.ReplicaMode
¶
Bases: IntEnum
Replica modes. Response to DbInfoCode.REPLICA_MODE or as value for DPBItem.SET_DB_REPLICA.
Source code in firebird/driver/types.py
firebird.driver.types.StmtInfoCode
¶
Bases: IntEnum
Statement information (isc_info_sql_*) codes.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.ReqInfoCode
¶
firebird.driver.types.ReqState
¶
firebird.driver.types.TraInfoCode
¶
Bases: IntEnum
Transaction information (isc_info_tra_*) codes.
Source code in firebird/driver/types.py
firebird.driver.types.TraInfoIsolation
¶
firebird.driver.types.TraInfoReadCommitted
¶
firebird.driver.types.TraInfoAccess
¶
firebird.driver.types.TraAccessMode
¶
firebird.driver.types.TraIsolation
¶
firebird.driver.types.TraReadCommitted
¶
firebird.driver.types.Isolation
¶
Bases: IntEnum
Transaction Isolation TPB parameters.
Note
Some members are specific to certain Firebird versions, indicated by comments.
- Reference firebird.driver.core tpb
Source code in firebird/driver/types.py
firebird.driver.types.TraLockResolution
¶
firebird.driver.types.TableShareMode
¶
firebird.driver.types.TableAccessMode
¶
firebird.driver.types.DefaultAction
¶
Bases: IntEnum
Default action when transaction is ended automatically.
Source code in firebird/driver/types.py
firebird.driver.types.StatementType
¶
firebird.driver.types.SQLDataType
¶
Bases: IntEnum
SQL data type.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.DPBItem
¶
Bases: IntEnum
Database Parameter Buffer (DPB) items, corresponding to isc_dpb_* constants (using VERSION2 codes).
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.TPBItem
¶
Bases: IntEnum
Transaction Parameter Buffer (DPB) items, corresponding to isc_tpb_* constants.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SPBItem
¶
Bases: IntEnum
isc_spb_* items.
Source code in firebird/driver/types.py
firebird.driver.types.BPBItem
¶
firebird.driver.types.BlobType
¶
firebird.driver.types.BlobStorage
¶
firebird.driver.types.ServerAction
¶
Bases: IntEnum
isc_action_svc_* items.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SrvDbInfoOption
¶
firebird.driver.types.SrvRepairOption
¶
Bases: IntEnum
Parameters for ServerAction.REPAIR.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SrvBackupOption
¶
Bases: IntEnum
Parameters for ServerAction.BACKUP.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SrvRestoreOption
¶
Bases: IntEnum
Parameters for ServerAction.RESTORE.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SrvNBackupOption
¶
Bases: IntEnum
Parameters for ServerAction.NBAK.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SrvTraceOption
¶
firebird.driver.types.SrvPropertiesOption
¶
Bases: IntEnum
Parameters for ServerAction.PROPERTIES.
Source code in firebird/driver/types.py
firebird.driver.types.SrvValidateOption
¶
firebird.driver.types.SrvUserOption
¶
Bases: IntEnum
Parameters for ServerAction.ADD_USER|DELETE_USER|MODIFY_USER|DISPLAY_USER.
Source code in firebird/driver/types.py
firebird.driver.types.DbAccessMode
¶
firebird.driver.types.DbSpaceReservation
¶
Bases: IntEnum
Values for isc_spb_prp_reserve_space.
Source code in firebird/driver/types.py
firebird.driver.types.DbWriteMode
¶
firebird.driver.types.ShutdownMode
¶
Bases: IntEnum
Values for isc_spb_prp_shutdown_mode.
Source code in firebird/driver/types.py
firebird.driver.types.OnlineMode
¶
firebird.driver.types.ShutdownMethod
¶
firebird.driver.types.TransactionState
¶
firebird.driver.types.DbProvider
¶
firebird.driver.types.DbClass
¶
firebird.driver.types.Implementation
¶
Bases: IntEnum
Implementation - Legacy format.
Source code in firebird/driver/types.py
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 | |
firebird.driver.types.ImpCPU
¶
firebird.driver.types.ImpOS
¶
firebird.driver.types.ImpCompiler
¶
firebird.driver.types.CancelType
¶
firebird.driver.types.DecfloatRound
¶
firebird.driver.types.DecfloatTraps
¶
Flags¶
firebird.driver.types.StateFlag
¶
firebird.driver.types.PreparePrefetchFlag
¶
Bases: IntFlag
Flags for Statement Prefetch.
Source code in firebird/driver/types.py
firebird.driver.types.StatementFlag
¶
firebird.driver.types.CursorFlag
¶
firebird.driver.types.ConnectionFlag
¶
firebird.driver.types.EncryptionFlag
¶
firebird.driver.types.ServerCapability
¶
Bases: IntFlag
Server capabilities (returned by isc_info_svc_capabilities).
Source code in firebird/driver/types.py
firebird.driver.types.SrvRepairFlag
¶
Bases: IntFlag
isc_spb_rpr_* flags used as options for the ServerAction.REPAIR service action.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SrvStatFlag
¶
Bases: IntFlag
isc_spb_sts_* flags for ServerAction.DB_STATS.
Source code in firebird/driver/types.py
firebird.driver.types.SrvBackupFlag
¶
Bases: IntFlag
isc_spb_bkp_* flags for ServerAction.BACKUP.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SrvRestoreFlag
¶
Bases: IntFlag
isc_spb_res_* flags for ServerAction.RESTORE.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SrvNBackupFlag
¶
Bases: IntFlag
isc_spb_nbk_* flags for ServerAction.NBAK.
Note
Some members are specific to certain Firebird versions, indicated by comments.
Source code in firebird/driver/types.py
firebird.driver.types.SrvPropertiesFlag
¶
firebird.driver.types.ImpFlags
¶
Dataclasses¶
firebird.driver.types.ItemMetadata
dataclass
¶
Information for single item from iMessageMetadata.
This dataclass is used internally, and it's not intended for general use.
Attributes:
| Name | Type | Description |
|---|---|---|
field |
str
|
Field name |
relation |
str
|
Relation name |
owner |
str
|
Owner name |
alias |
str
|
Field alias |
datatype |
SQLDataType
|
Data type |
nullable |
bool
|
Whether NULLs are allowed |
subtype |
int
|
Data sub-type |
length |
int
|
Size of raw field data in message buffer |
scale |
int
|
Field scale |
charset |
int
|
Character set |
offset |
int
|
Offset of raw field data in message buffer |
null_offset |
int
|
Offset of null flag in message buffer |
Source code in firebird/driver/types.py
firebird.driver.types.TableAccessStats
dataclass
¶
Table access statistics.
Data structure returned by .Connection.get_table_access_stats().
Attributes:
| Name | Type | Description |
|---|---|---|
table_id |
int
|
Relation ID |
sequential |
int
|
Number of sequential table scans (row reads) |
indexed |
int
|
Number of reads done via an index |
inserts |
int
|
Number of inserts |
updates |
int
|
Number of updates |
deletes |
int
|
Number of deleted |
backouts |
int
|
Number of removals of a version of a record |
purges |
int
|
Number of removals of old versions of fully mature records (records that are committed, so that older ancestor versions are no longer needed) |
expunges |
int
|
Number of removals of a record and all of its ancestors, for records whose deletions have been committed |
Source code in firebird/driver/types.py
firebird.driver.types.UserInfo
dataclass
¶
Information about Firebird user.
Data structure returned by .Service.get_user() and .Service.get_users().
Attributes:
| Name | Type | Description |
|---|---|---|
user_name |
str
|
User (login) name |
password |
str
|
User password |
first_name |
str
|
First name |
middle_name |
str
|
Middle name |
last_name |
str
|
Last name |
user_id |
int
|
User ID |
group_id |
int
|
User Group ID |
group_name |
str
|
Group name |
admin |
bool
|
True is user has admin priviledges |
Source code in firebird/driver/types.py
firebird.driver.types.BCD
dataclass
¶
firebird.driver.types.TraceSession
dataclass
¶
Information about active trace session.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Session ID number |
user |
str
|
User name |
timestamp |
datetime
|
Session start timestamp |
name |
str
|
Session name (if defined) |
flags |
list
|
List with session flag names |
plugins |
list
|
List with trace plugins for this session |
Source code in firebird/driver/types.py
firebird.driver.types.ImpData
dataclass
¶
Information about Firebird implementation (new format).
Attributes:
| Name | Type | Description |
|---|---|---|
cpu |
ImpCPU
|
CPU identification |
os |
ImpOS
|
Operating system |
compiler |
ImpCompiler
|
Compiler indentification |
flags |
ImpFlags
|
Implementation flags |
db_class |
DbClass
|
Provider class |
depth |
int
|
Depth of info stack |
Source code in firebird/driver/types.py
firebird.driver.types.ImpDataOld
dataclass
¶
Information about Firebird implementation (new format).
Attributes:
| Name | Type | Description |
|---|---|---|
implementation |
Implementation
|
CPU and OS identification |
db_class |
DbClass
|
Provider class |
Source code in firebird/driver/types.py
Helper functions¶
firebird.driver.types.get_timezone(timezone: str | None = None) -> datetime.tzinfo
¶
Returns datetime.tzinfo for specified time zone.
This is preferred method to obtain timezone information for construction of timezone-aware
datetime.datetime and datetime.time objects. Current implementation uses dateutil.tz
for timezone tzinfo objects, but adds metadata neccessary to store timezone regions into
database instead zoned time, and to handle offset-based timezones in format required by
Firebird.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timezone
|
str | None
|
Timezone region specification or UTC offset. |
None
|