TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/obedc295/proyect_dw/llms.txt
Use this file to discover all available pages before exploring further.
Settings class is the single source of truth for database connectivity in ETL Dinámico para Data Warehouse. At module import time, load_dotenv() populates the process environment from a .env file, and then the Settings class body executes its statements at class-definition time — meaning OLTP_URL and OLAP_URL are built once, eagerly, before any application code runs. The resulting percent-encoded mssql+pyodbc URLs are then consumed by DatabaseClient to create SQLAlchemy engine instances for both the OLTP source and the OLAP Data Warehouse.
How It Works
Settings does not rely on __init__ or instance methods. Every attribute is defined directly in the class body, so the entire URL-building logic runs exactly once when Python first imports src.config.settings. The process has three steps:
- Load environment variables —
load_dotenv()reads.envfrom the working directory (or any parent directory) and merges its key-value pairs intoos.environ. - Build raw ODBC strings —
raw_oltpandraw_olapare plain semicolon-delimited ODBC connection strings assembled with f-strings from the environment variables. - Percent-encode into SQLAlchemy URLs —
urllib.parse.quote_plus()encodes the raw ODBC string so it can be safely embedded as a query-string value in the finalmssql+pyodbc:///?odbc_connect=…URL. This is especially important for backslashes in named SQL Server instances (e.g.,ELIEL\SQLEXPRESS→ELIEL%5CSQLEXPRESS).
Fixed ODBC Parameters
Both raw connection strings include two fixed parameters that are not sourced from the environment:| Parameter | Value | Purpose |
|---|---|---|
Trusted_Connection | yes | Uses Windows Authentication — no username or password required |
TrustServerCertificate | yes | Skips SSL certificate validation, required for local/development SQL Server instances |
URL Format
After encoding, each URL follows this structure:Environment Variables
These six variables must be present in.env (or in the system environment) before settings.py is imported. A minimal .env for a local development setup looks like:
SQL Server instance name (or host) for the OLTP source database. Named instances use a backslash separator —
quote_plus will encode this to %5C automatically.Example: ELIEL\SQLEXPRESSThe name of the OLTP source database on the SQL Server instance specified by
OLTP_SERVER.Example: NORTHWNDThe ODBC driver string exactly as registered in the system ODBC driver manager. The driver must be installed on the host running the ETL.Example:
ODBC Driver 17 for SQL ServerSQL Server instance name (or host) for the OLAP Data Warehouse target database.Example:
ELIEL\SQLEXPRESSThe name of the Data Warehouse database on the SQL Server instance specified by
OLAP_SERVER.Example: DataWarehouseThe ODBC driver string for the OLAP connection. Can differ from
OLTP_DRIVER if both databases are served by different SQL Server versions.Example: ODBC Driver 17 for SQL ServerClass Attributes
Fully percent-encoded SQLAlchemy connection URL for the OLTP source database. Built from
OLTP_DRIVER, OLTP_SERVER, and OLTP_DATABASE plus the fixed Trusted_Connection=yes and TrustServerCertificate=yes parameters.Format: mssql+pyodbc:///?odbc_connect=<encoded_odbc_string>Fully percent-encoded SQLAlchemy connection URL for the OLAP Data Warehouse. Built from
OLAP_DRIVER, OLAP_SERVER, and OLAP_DATABASE plus the same fixed authentication parameters.Format: mssql+pyodbc:///?odbc_connect=<encoded_odbc_string>The settings Singleton
A single Settings instance named settings is created at the bottom of the module and is the canonical object to import throughout the project:
from src.config.settings import settings returns the same object — Settings.__init__ is never invoked more than once per interpreter session.
DatabaseClient is the only intended consumer of settings.OLTP_URL and settings.OLAP_URL. Application code, pipeline modules, and the Streamlit UI should import DatabaseClient directly rather than reading the raw URLs from Settings. This keeps connection-management logic centralized and makes it easier to swap engines (e.g., for testing) without touching call sites.Dependencies
Settings relies on the following packages from requirements.txt:
| Package | Version | Role |
|---|---|---|
python-dotenv | >=1.0.0 | Loads .env into os.environ via load_dotenv() |
SQLAlchemy | >=2.0.0 | Consumes the URL strings to create engine instances |
pyodbc | >=5.0.0 | Low-level ODBC driver bridge used by the mssql+pyodbc dialect |