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¶
- class firebird.driver.config.DriverConfig(name: str)[source]¶
Bases:
ConfigMain 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_defaultsandserver_defaultssections. When reading multiple files, options from later files override those from earlier ones.- Parameters:
name (str) –
- get_database(name: str) DatabaseConfig[source]¶
Returns database configuration.
- Parameters:
name (str) –
- Return type:
- get_server(name: str) ServerConfig[source]¶
Returns server configuration.
- Parameters:
name (str) –
- Return type:
- read(filenames: str | Iterable, encoding: str | None = None)[source]¶
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.
- read_dict(dictionary: dict[str, str]) None[source]¶
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.
- read_file(f)[source]¶
Read configuration from a file-like object.
The
fargument must be iterable, returning one line at a time.
- read_string(string: str) None[source]¶
Read configuration from a given string.
- Parameters:
string (str) –
- Return type:
None
- register_database(name: str, config: str | None = None) DatabaseConfig[source]¶
Register database.
- Parameters:
- Returns:
For newly registered database
- Return type:
- Raises:
ValueError – If database is already registered.
- register_server(name: str, config: str | None = None) ServerConfig[source]¶
Register server.
- Parameters:
- Returns:
For newly registered server
- Return type:
- Raises:
ValueError – If server is already registered.
- databases: ConfigListOption¶
Registered databases
- db_defaults: DatabaseConfig¶
Default database configuration (‘firebird.db.defaults’)
- server_defaults: ServerConfig¶
Default server configuration (‘firebird.server.defaults’)
- servers: ConfigListOption¶
Registered servers
- class firebird.driver.config.ServerConfig(name: str, *, optional: bool = False, description: str | None = None)[source]¶
Bases:
ConfigRepresents configuration options specific to a named Firebird server entry.
- encoding_errors: StrOption¶
Handler used for encoding errors. See
codecs error handlersfor details.
- trusted_auth: BoolOption¶
False
- Type:
Use trusted authentication, default
- class firebird.driver.config.DatabaseConfig(name: str, *, optional: bool = False, description: str | None = None)[source]¶
Bases:
ConfigRepresents configuration options specific to a named Firebird database entry, including connection and creation parameters.
- decfloat_round: EnumOption¶
Set DECFLOAT ROUND [Firebird 4], value is
DecfloatRound
- decfloat_traps: ListOption¶
Specifies which DECFLOAT exceptional conditions should cause a trap (raise an error) [Firebird 4]. Accepts a list of .DecfloatTraps enum members.
- forced_writes: BoolOption¶
Database create option. Write mode (True = sync/False = async).
- no_linger: BoolOption¶
Do not use linger for database connection
- parallel_workers¶
Number of parallel workers
- protocol: EnumOption¶
Network protocol to use for the connection. Value must be a member of the .NetProtocol enum.
- reserve_space: BoolOption¶
Database create option. Data page space usage (True = reserve space, False = Use all space).
- trusted_auth: BoolOption¶
False
- Type:
Use trusted authentication, default
- utf8filename: BoolOption¶
Specifies whether the database parameter (filename) is encoded in UTF-8 when passed to the server.
Globals¶
- firebird.driver.config.driver_config: DriverConfig¶
Global driver configuration instance. Load settings from files/strings/dicts into this object before connecting, or modify its attributes directly for programmatic configuration.