firebird.driver.config¶
This module defines the configuration system for the firebird-driver.
It uses an INI-style format managed via the DriverConfig class, which
allows defining settings for the driver itself, default server/database
parameters, and named configurations for specific servers and databases.
Configuration can be loaded from files, strings, or dictionaries, and
supports environment variable interpolation. The primary interaction point
is usually the global driver_config instance.
Classes¶
firebird.driver.config.DriverConfig
¶
Bases: Config
Main configuration object for the Firebird driver. Holds global settings, default configurations, and lists of registered servers and databases.
Settings loaded from specific server/database sections override those in the db_defaults
and server_defaults sections. When reading multiple files, options from later files
override those from earlier ones.
Source code in firebird/driver/config.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 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 | |
configs: list[Config]
property
¶
List of nested Config instances associated with this instance.
Includes:
Configinstances directly assigned as attributes.- The
Configinstance held by anyConfigOptionattribute. - All
Configinstances within the list held by anyConfigListOptionattribute.
databases: ConfigListOption
instance-attribute
¶
Registered databases
db_defaults: DatabaseConfig
instance-attribute
¶
Default database configuration ('firebird.db.defaults')
fb_client_library: StrOption
instance-attribute
¶
Path to Firebird client library
name: str
property
¶
Name associated with Config (default section name).
optional: bool
property
¶
Whether config is optional (False) or mandatory (True) for configuration file
(see load_config() for details).
options: list[Option]
property
¶
List of Option instances directly defined as attributes of this Config instance.
server_defaults: ServerConfig
instance-attribute
¶
Default server configuration ('firebird.server.defaults')
servers: ConfigListOption
instance-attribute
¶
Registered servers
stream_blob_threshold: IntOption
instance-attribute
¶
BLOB size threshold. Larger BLOBs are streamed automatically; -1 disables this.
clear(*, to_default: bool = True) -> None
¶
Clears all owned options and options in owned sub-configs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_default
|
bool
|
If True, sets the option values to defaults, else to None. |
True
|
Source code in firebird/base/config.py
get_config(*, plain: bool = False) -> str
¶
Returns string containing text lines suitable for use in configuration file processed with configparser.ConfigParser.
Important
When config is optional and the name is an empty string, it returns empty string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plain
|
bool
|
When True, it outputs only the option values. When False, it includes also option descriptions and other helpful information. |
False
|
Source code in firebird/base/config.py
get_database(name: str) -> DatabaseConfig
¶
get_description() -> str
¶
Configuration description. Can span multiple lines.
Note: If description is not provided on instance creation, class doc string.
get_server(name: str) -> ServerConfig
¶
load_config(config: ConfigParser, section: str | None = None) -> None
¶
Update configuration values from a ConfigParser instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ConfigParser
|
|
required |
section
|
str | None
|
Name of the |
None
|
Behavior
- Reads values for directly owned
Optioninstances from the specifiedsection. - Recursively calls
load_configon directly ownedConfiginstances using their respectivenameattribute as the section name. - Recursively calls
load_configonConfiginstances referenced by ownedConfigOptionandConfigListOptionvalues, using the section names stored within those options.
Raises:
| Type | Description |
|---|---|
Error
|
If |
KeyError
|
Propagated if an invalid section name is used for a nested config. |
ValueError
|
Propagated if an option string cannot be parsed correctly. |
Source code in firebird/base/config.py
load_proto(proto: ConfigProto) -> None
¶
Deserialize value from ConfigProto message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proto
|
ConfigProto
|
Protobuf message that may contains option values and sub-configs. |
required |
Source code in firebird/base/config.py
read(filenames: str | Iterable, encoding: str | None = None)
¶
Read configuration from a filename or an iterable of filenames.
Files that cannot be opened are silently ignored; this is designed so that you can specify an iterable of potential configuration file locations (e.g. current directory, user's home directory, systemwide directory), and all existing configuration files in the iterable will be read. A single filename may also be given.
Return list of successfully read files.
Source code in firebird/driver/config.py
read_dict(dictionary: dict[str, str]) -> None
¶
Read configuration from a dictionary.
Keys are section names, values are dictionaries with keys and values that should be present in the section. If the used dictionary type preserves order, sections and their keys will be added in order.
All types held in the dictionary are converted to strings during reading, including section names, option names and keys.
Source code in firebird/driver/config.py
read_file(f)
¶
Read configuration from a file-like object.
The f argument must be iterable, returning one line at a time.
Source code in firebird/driver/config.py
read_string(string: str) -> None
¶
Read configuration from a given string.
register_database(name: str, config: str | None = None) -> DatabaseConfig
¶
Register database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Database name. |
required |
config
|
str | None
|
Optional database configuration string in ConfigParser format in [name] section. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
DatabaseConfig |
DatabaseConfig
|
For newly registered database |
Raises:
| Type | Description |
|---|---|
ValueError
|
If database is already registered. |
Source code in firebird/driver/config.py
register_server(name: str, config: str | None = None) -> ServerConfig
¶
Register server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Server name. |
required |
config
|
str | None
|
Optional server configuration string in ConfigParser format in [name] section. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ServerConfig |
ServerConfig
|
For newly registered server |
Raises:
| Type | Description |
|---|---|
ValueError
|
If server is already registered. |
Source code in firebird/driver/config.py
save_proto(proto: ConfigProto) -> None
¶
Serialize value into ConfigProto message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proto
|
ConfigProto
|
Protobuf message where option values and sub-configs should be stored. |
required |
Source code in firebird/base/config.py
validate() -> None
¶
Recursively validates all directly owned options and sub-configs.
Checks whether
- all required options have a non-
Nonevalue. - required
ConfigOptionvalues have a non-empty section name. - required
ConfigListOptionvalues have a non-empty list. - all options are defined as instance attributes with the same name as
option.name. - calls
validate()on all nestedConfiginstances (direct attributes, values ofConfigOption, and items inConfigListOption).
Raises:
| Type | Description |
|---|---|
Error
|
When any validation constraint is violated. |
Source code in firebird/base/config.py
firebird.driver.config.ServerConfig
¶
Bases: Config
Represents configuration options specific to a named Firebird server entry.
Source code in firebird/driver/config.py
auth_plugin_list: StrOption
instance-attribute
¶
List of authentication plugins override
config: StrOption
instance-attribute
¶
Configuration override
configs: list[Config]
property
¶
List of nested Config instances associated with this instance.
Includes:
Configinstances directly assigned as attributes.- The
Configinstance held by anyConfigOptionattribute. - All
Configinstances within the list held by anyConfigListOptionattribute.
encoding: StrOption
instance-attribute
¶
Encoding used for text data exchange with server
encoding_errors: StrOption
instance-attribute
¶
Handler used for encoding errors. See codecs error handlers <codecs> for details.
host: StrOption
instance-attribute
¶
Server host machine specification
name: str
property
¶
Name associated with Config (default section name).
optional: bool
property
¶
Whether config is optional (False) or mandatory (True) for configuration file
(see load_config() for details).
options: list[Option]
property
¶
List of Option instances directly defined as attributes of this Config instance.
password: StrOption
instance-attribute
¶
Default user password, default is envar ISC_PASSWORD or None if not specified
port: StrOption
instance-attribute
¶
Port used by Firebird server
trusted_auth: BoolOption
instance-attribute
¶
Use trusted authentication, default: False
user: StrOption
instance-attribute
¶
Defaul user name, default is envar ISC_USER or None if not specified
clear(*, to_default: bool = True) -> None
¶
Clears all owned options and options in owned sub-configs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_default
|
bool
|
If True, sets the option values to defaults, else to None. |
True
|
Source code in firebird/base/config.py
get_config(*, plain: bool = False) -> str
¶
Returns string containing text lines suitable for use in configuration file processed with configparser.ConfigParser.
Important
When config is optional and the name is an empty string, it returns empty string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plain
|
bool
|
When True, it outputs only the option values. When False, it includes also option descriptions and other helpful information. |
False
|
Source code in firebird/base/config.py
get_description() -> str
¶
Configuration description. Can span multiple lines.
Note: If description is not provided on instance creation, class doc string.
load_config(config: ConfigParser, section: str | None = None) -> None
¶
Update configuration values from a ConfigParser instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ConfigParser
|
|
required |
section
|
str | None
|
Name of the |
None
|
Behavior
- Reads values for directly owned
Optioninstances from the specifiedsection. - Recursively calls
load_configon directly ownedConfiginstances using their respectivenameattribute as the section name. - Recursively calls
load_configonConfiginstances referenced by ownedConfigOptionandConfigListOptionvalues, using the section names stored within those options.
Raises:
| Type | Description |
|---|---|
Error
|
If |
KeyError
|
Propagated if an invalid section name is used for a nested config. |
ValueError
|
Propagated if an option string cannot be parsed correctly. |
Source code in firebird/base/config.py
load_proto(proto: ConfigProto) -> None
¶
Deserialize value from ConfigProto message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proto
|
ConfigProto
|
Protobuf message that may contains option values and sub-configs. |
required |
Source code in firebird/base/config.py
save_proto(proto: ConfigProto) -> None
¶
Serialize value into ConfigProto message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proto
|
ConfigProto
|
Protobuf message where option values and sub-configs should be stored. |
required |
Source code in firebird/base/config.py
validate() -> None
¶
Recursively validates all directly owned options and sub-configs.
Checks whether
- all required options have a non-
Nonevalue. - required
ConfigOptionvalues have a non-empty section name. - required
ConfigListOptionvalues have a non-empty list. - all options are defined as instance attributes with the same name as
option.name. - calls
validate()on all nestedConfiginstances (direct attributes, values ofConfigOption, and items inConfigListOption).
Raises:
| Type | Description |
|---|---|
Error
|
When any validation constraint is violated. |
Source code in firebird/base/config.py
firebird.driver.config.DatabaseConfig
¶
Bases: Config
Represents configuration options specific to a named Firebird database entry, including connection and creation parameters.
Source code in firebird/driver/config.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
auth_plugin_list: StrOption
instance-attribute
¶
List of authentication plugins override
cache_size: IntOption
instance-attribute
¶
Page cache size override for database connection
charset: StrOption
instance-attribute
¶
Character set for database connection
config: StrOption
instance-attribute
¶
Configuration override
configs: list[Config]
property
¶
List of nested Config instances associated with this instance.
Includes:
Configinstances directly assigned as attributes.- The
Configinstance held by anyConfigOptionattribute. - All
Configinstances within the list held by anyConfigListOptionattribute.
database: StrOption
instance-attribute
¶
Database file specification or alias
db_cache_size: IntOption
instance-attribute
¶
Database create option. Page cache size override for database.
db_charset: StrOption
instance-attribute
¶
Database create option. Character set for the database.
db_sql_dialect: IntOption
instance-attribute
¶
Database create option. SQL dialect for the database.
decfloat_round: EnumOption
instance-attribute
¶
Set DECFLOAT ROUND [Firebird 4], value is .DecfloatRound
decfloat_traps: ListOption
instance-attribute
¶
Specifies which DECFLOAT exceptional conditions should cause a trap (raise an error) [Firebird 4]. Accepts a list of .DecfloatTraps enum members.
dsn: StrOption
instance-attribute
¶
Database connection string
dummy_packet_interval: IntOption
instance-attribute
¶
Dummy packet interval for this database connection
forced_writes: BoolOption
instance-attribute
¶
Database create option. Write mode (True = sync/False = async).
name: str
property
¶
Name associated with Config (default section name).
no_linger: BoolOption
instance-attribute
¶
Do not use linger for database connection
optional: bool
property
¶
Whether config is optional (False) or mandatory (True) for configuration file
(see load_config() for details).
options: list[Option]
property
¶
List of Option instances directly defined as attributes of this Config instance.
page_size: IntOption
instance-attribute
¶
Database create option. Page size to be used.
parallel_workers
instance-attribute
¶
Number of parallel workers
password: StrOption
instance-attribute
¶
Default user password, default is envar ISC_PASSWORD or None if not specified
protocol: EnumOption
instance-attribute
¶
Network protocol to use for the connection. Value must be a member of the .NetProtocol enum.
reserve_space: BoolOption
instance-attribute
¶
Database create option. Data page space usage (True = reserve space, False = Use all space).
role: StrOption
instance-attribute
¶
User role
server: StrOption
instance-attribute
¶
Name of server where database is located
session_time_zone: StrOption
instance-attribute
¶
Session time zone [Firebird 4]
set_bind: StrOption
instance-attribute
¶
Set BIND [Firebird 4]
sql_dialect: IntOption
instance-attribute
¶
SQL Dialect for database connection, default: 3
sweep_interval: IntOption
instance-attribute
¶
Database create option. Sweep interval for the database.
timeout: IntOption
instance-attribute
¶
Connection timeout
trusted_auth: BoolOption
instance-attribute
¶
Use trusted authentication, default: False
user: StrOption
instance-attribute
¶
Defaul user name, default is envar ISC_USER or None if not specified
utf8filename: BoolOption
instance-attribute
¶
Specifies whether the database parameter (filename) is encoded in UTF-8 when passed to the server.
clear(*, to_default: bool = True) -> None
¶
Clears all owned options and options in owned sub-configs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_default
|
bool
|
If True, sets the option values to defaults, else to None. |
True
|
Source code in firebird/base/config.py
get_config(*, plain: bool = False) -> str
¶
Returns string containing text lines suitable for use in configuration file processed with configparser.ConfigParser.
Important
When config is optional and the name is an empty string, it returns empty string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plain
|
bool
|
When True, it outputs only the option values. When False, it includes also option descriptions and other helpful information. |
False
|
Source code in firebird/base/config.py
get_description() -> str
¶
Configuration description. Can span multiple lines.
Note: If description is not provided on instance creation, class doc string.
load_config(config: ConfigParser, section: str | None = None) -> None
¶
Update configuration values from a ConfigParser instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ConfigParser
|
|
required |
section
|
str | None
|
Name of the |
None
|
Behavior
- Reads values for directly owned
Optioninstances from the specifiedsection. - Recursively calls
load_configon directly ownedConfiginstances using their respectivenameattribute as the section name. - Recursively calls
load_configonConfiginstances referenced by ownedConfigOptionandConfigListOptionvalues, using the section names stored within those options.
Raises:
| Type | Description |
|---|---|
Error
|
If |
KeyError
|
Propagated if an invalid section name is used for a nested config. |
ValueError
|
Propagated if an option string cannot be parsed correctly. |
Source code in firebird/base/config.py
load_proto(proto: ConfigProto) -> None
¶
Deserialize value from ConfigProto message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proto
|
ConfigProto
|
Protobuf message that may contains option values and sub-configs. |
required |
Source code in firebird/base/config.py
save_proto(proto: ConfigProto) -> None
¶
Serialize value into ConfigProto message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proto
|
ConfigProto
|
Protobuf message where option values and sub-configs should be stored. |
required |
Source code in firebird/base/config.py
validate() -> None
¶
Recursively validates all directly owned options and sub-configs.
Checks whether
- all required options have a non-
Nonevalue. - required
ConfigOptionvalues have a non-empty section name. - required
ConfigListOptionvalues have a non-empty list. - all options are defined as instance attributes with the same name as
option.name. - calls
validate()on all nestedConfiginstances (direct attributes, values ofConfigOption, and items inConfigListOption).
Raises:
| Type | Description |
|---|---|
Error
|
When any validation constraint is violated. |
Source code in firebird/base/config.py
Globals¶
firebird.driver.config.driver_config: DriverConfig
module-attribute
¶
Global driver configuration instance. Load settings from files/strings/dicts into this object before connecting, or modify its attributes directly for programmatic configuration.