Settings¶
Configuration management for PyFIA.
Overview¶
PyFIA uses a centralized settings system with support for environment variables.
from pyfia import settings
# View current settings
print(settings.database_path)
print(settings.max_threads)
# Modify settings
settings.max_threads = 8
settings.cache_enabled = True
Environment Variables¶
| Variable | Description | Default |
|---|---|---|
PYFIA_DATABASE_PATH |
Default database path | fia.duckdb |
PYFIA_DATABASE_ENGINE |
Database engine | duckdb |
PYFIA_MAX_THREADS |
Max processing threads | 4 |
PYFIA_CACHE_ENABLED |
Enable caching | true |
PYFIA_LOG_LEVEL |
Logging level | CRITICAL |
Class Reference¶
PyFIASettings
¶
Bases: BaseSettings
Central settings for pyFIA with environment variable support.
Environment variables are prefixed with PYFIA_. For example: PYFIA_DATABASE_PATH, PYFIA_LOG_LEVEL
Also supports legacy environment variables FIA_DB_PATH and FIA_DB_ENGINE for backwards compatibility.
validate_engine
classmethod
¶
Validate database engine choice.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Database engine to validate
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Validated and lowercased engine name |
Source code in src/pyfia/core/settings.py
validate_log_level
classmethod
¶
Validate log level.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Log level to validate
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Validated and uppercased log level |
Source code in src/pyfia/core/settings.py
validate_database_path
classmethod
¶
Validate database path exists.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Database path to validate
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
Validated database path |
Source code in src/pyfia/core/settings.py
create_directories
¶
Create necessary directories if they don't exist.
| RETURNS | DESCRIPTION |
|---|---|
None
|
|
Source code in src/pyfia/core/settings.py
get_connection_string
¶
Get database connection string.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Database connection string for the configured engine |
Source code in src/pyfia/core/settings.py
Helper Functions¶
get_default_db_path
¶
Get the default database path.
Checks environment variables and settings for database path.
| RETURNS | DESCRIPTION |
|---|---|
Path
|
Path to the default database |
Source code in src/pyfia/core/settings.py
get_default_engine
¶
Get the default database engine.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Default engine type ("sqlite" or "duckdb") |