Core Constants & Enums
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Core Constants & Enums module serves as the foundational Single Source of Truth (SSOT) for the FLEXT DB Oracle integration library. It centralizes Oracle-specific configuration defaults, data type mappings, validation rules, and performance thresholds. This module is critical for ensuring architectural consistency across the application, domain, and infrastructure layers.
By utilizing a unified class pattern, the module provides structured access to constants used in connection pooling, SQL generation, and schema introspection. It integrates closely with the FLEXT Core ecosystem to maintain standard naming conventions and type safety requirements.
Sources: src/README.md:27-31, src/flext_db_oracle/constants.py:1-12
Architectural Overview
The constants are primarily encapsulated within the FlextDbOracleConstants class, which extends the base FLEXT CLI constants. Within this, the DbOracle nested class contains the flat SSOT members categorized into logical domains such as networking, query limits, and environment mappings.
The diagram above shows the hierarchical relationship of constants and enums within the FlextDbOracleConstants namespace.
Sources: src/flext_db_oracle/constants.py:33-47, tests/unit/test_constants.py:133-143
Configuration and Networking
The library defines a set of default values for Oracle connections to ensure immediate out-of-the-box functionality while providing strict boundaries for validation.
Default Connection Settings
| Constant | Default Value | Description |
|---|---|---|
DEFAULT_HOST | localhost | Default database host |
DEFAULT_PORT | 1521 | Standard Oracle listener port |
DEFAULT_SERVICE_NAME | XEPDB1 | Default pluggable database service |
DEFAULT_SID | XE | Default System ID |
DEFAULT_USERNAME | system | Default administrative user |
MIN_PORT | 1 | Minimum allowed network port |
MAX_PORT | 65535 | Maximum allowed network port |
Sources: src/flext_db_oracle/constants.py:65-72, tests/unit/test_constants.py:30-45
Connection Lifecycle and Pooling
The pooling constants manage resource allocation and lifecycle for database connections.
- Pool Sizing: Defaults to a minimum of 2 and a maximum of 20 connections.
- Timeouts: Default connection and query timeouts are set to 60 seconds, while the maximum query timeout is 3600 seconds.
- Recycling: Connections are recycled every 3600 seconds by default to prevent stale handles.
Sources: src/flext_db_oracle/constants.py:73-82, tests/unit/test_constants.py:48-60
Data Types and Schema Mapping
Oracle-specific data types are managed through the DataType enumeration and the SINGER_TYPE_MAP to facilitate integration with the Singer.io ecosystem.
DataType Enumeration
- VARCHAR2: Standard variable-length character data.
- NUMBER: Fixed and floating-point numeric data.
- DATE / TIMESTAMP: Temporal data types.
- CLOB / BLOB: Large character and binary objects.
Sources: src/flext_db_oracle/constants.py:241-250, tests/unit/test_constants.py:77-83
Singer Type Integration
The system provides a mapping between Singer JSON Schema types and Oracle DDL types to automate table creation.
SINGER_TYPE_MAP = {
"string": "VARCHAR2(4000)",
"integer": "NUMBER(38)",
"number": "NUMBER",
"boolean": "NUMBER(1)",
"array": "CLOB",
"date-time": "TIMESTAMP",
"date": "DATE"
}
Sources: src/flext_db_oracle/constants.py:307-317, tests/unit/test_services.py:108-115
SQL Generation and Reserved Words
To prevent SQL injection and ensure syntactical correctness, the library maintains comprehensive lists of reserved keywords and identifier patterns.
Identifier Validation
Identifiers are validated against specific regex patterns. Oracle identifiers typically follow the ^[A-Z][A-Z0-9_$#]*$ pattern and are restricted to 30 characters in older versions, though the library supports lengths up to 128 characters for modern schemas.
Sources: src/flext_db_oracle/constants.py:118-126, tests/unit/test_constants.py:96-105
Reserved Keywords
The ORACLE_RESERVED set includes core DDL and DML commands that cannot be used as unquoted identifiers, such as SELECT, TABLE, INDEX, and CONSTRAINT.
Sources: src/flext_db_oracle/constants.py:155-190, tests/unit/test_constants.py:110-115
Performance Thresholds
The library includes "Health and Performance" constants used by the observability layer to categorize operation latency.
| Category | Threshold (ms) | Description |
|---|---|---|
| Excellent | < 100 | Highly optimized query or fast connection. |
| Good | < 500 | Acceptable performance for standard operations. |
| Acceptable | < 2000 | Upper limit before warning triggers. |
| Warning | > 5000 | Performance warning threshold in seconds. |
Sources: src/flext_db_oracle/constants.py:105-110, tests/unit/test_constants.py:65-73
Environment Variable Mappings
The library maps system environment variables to internal settings using prefixes like ORACLE_ and FLEXT_TARGET_ORACLE_.
This flow illustrates how environment variables are resolved into configuration settings.
Sources: src/flext_db_oracle/constants.py:318-330, tests/unit/test_constants.py:120-131
Conclusion
The Core Constants & Enums module provides the structural rigidity required for enterprise-grade Oracle integrations. By centralizing defaults, performance gates, and type mappings, it ensures that the FlextDbOracleApi and FlextDbOracleServices operate with predictable, validated, and optimized parameters. This centralization simplifies maintenance and ensures that changes to Oracle's technical boundaries are reflected across the entire library from a single point.