Skip to content
GitHub

Configuration

All database configuration lives under the sql key in application.yaml. The provider auto-injects DatabaseConfig — no manual loading needed.

Config section: sql | Env prefix: LEX_SQL__ | Nested delimiter: __

sql:
enabled: true
backend:
url: postgresql+asyncpg://user:pass@localhost/mydb
pool:
min_size: 2
max_size: 10
operations:
echo: false
Terminal window
export LEX_SQL__BACKEND__URL=postgresql+asyncpg://user:pass@localhost/mydb
export LEX_SQL__POOL__MIN_SIZE=2

KeyTypeDefaultEnv VarDescription
enabledboolTrueLEX_SQL__ENABLEDEnable the database module
backendDatabaseBackendConfigsqlite:///piccolina.dbLEX_SQL__BACKEND__*Connection URL and driver
poolDatabasePoolConfig(see below)LEX_SQL__POOL__*Connection pool settings
operationsDatabaseOperationConfig(see below)LEX_SQL__OPERATIONS__*Operation settings
outboxDatabaseOutboxConfig(see below)LEX_SQL__OUTBOX__*Outbox pattern settings
migrationsDatabaseMigrationConfig(see below)LEX_SQL__MIGRATIONS__*Migration settings
audit_hmac_keystr | NoneNoneLEX_SQL__AUDIT_HMAC_KEYHMAC key for audit signing
backendslist[NamedDatabaseConfig][]LEX_SQL__BACKENDSMulti-database backends

KeyTypeDefaultEnv VarDescription
urlSecretStrrequiredLEX_SQL__BACKEND__URLDatabase connection URL

Valid URL prefixes: sqlite, postgresql, postgres, mysql, mariadb, oracle, mssql, custom.


KeyTypeDefaultEnv VarDescription
min_sizeint1LEX_SQL__POOL__MIN_SIZEMinimum pool connections
max_sizeint10LEX_SQL__POOL__MAX_SIZEMaximum pool connections
max_overflowint5LEX_SQL__POOL__MAX_OVERFLOWMax overflow connections
recycleint3600LEX_SQL__POOL__RECYCLEConnection recycle time (seconds)
timeoutfloat30.0LEX_SQL__POOL__TIMEOUTPool timeout (seconds)
acquire_timeoutDuration30sLEX_SQL__POOL__ACQUIRE_TIMEOUTConnection acquire timeout
idle_timeoutDuration5mLEX_SQL__POOL__IDLE_TIMEOUTIdle connection timeout
max_lifetimeDuration1hLEX_SQL__POOL__MAX_LIFETIMEMax connection lifetime

KeyTypeDefaultEnv VarDescription
echoboolFalseLEX_SQL__OPERATIONS__ECHOLog all SQL statements
statement_timeoutDuration60sLEX_SQL__OPERATIONS__STATEMENT_TIMEOUTMax query execution time

KeyTypeDefaultEnv VarDescription
enabledboolTrueLEX_SQL__OUTBOX__ENABLEDEnable outbox pattern
poll_intervalDuration5sLEX_SQL__OUTBOX__POLL_INTERVALOutbox poll interval
batch_max_ageDuration30sLEX_SQL__OUTBOX__BATCH_MAX_AGEMax age for outbox batches

KeyTypeDefaultEnv VarDescription
lock_timeoutDuration30sLEX_SQL__MIGRATIONS__LOCK_TIMEOUTMigration lock timeout

KeyTypeDefaultEnv VarDescription
namestrrequiredLEX_SQL__BACKENDS__0__NAMEUnique backend name
backendDatabaseBackendConfigrequiredLEX_SQL__BACKENDS__0__BACKEND__*Connection config
primaryboolFalseLEX_SQL__BACKENDS__0__PRIMARYPrimary backend (unnamed bindings)
poolDatabasePoolConfigmin_size=2LEX_SQL__BACKENDS__0__POOL__*Per-backend pool settings
migration_dirstr | NoneNoneLEX_SQL__BACKENDS__0__MIGRATION_DIRAlembic dir for this backend

KeyTypeDefaultDescription
default_page_sizeint20Default pagination page size
max_page_sizeint100Maximum allowed page size
default_cursor_sizeint20Default cursor pagination size

application.yaml
sql:
enabled: true
backend:
url: postgresql+asyncpg://user:password@localhost:5432/mydb
pool:
min_size: 2
max_size: 20
timeout: 30
operations:
echo: false
audit_hmac_key: "${AUDIT_HMAC_KEY}"

Environment override equivalent:

Terminal window
export LEX_SQL__BACKEND__URL=postgresql+asyncpg://user:password@localhost:5432/mydb
export LEX_SQL__POOL__MIN_SIZE=5
export LEX_SQL__POOL__MAX_SIZE=30
export LEX_SQL__AUDIT_HMAC_KEY=my-hmac-key
sql:
backends:
- name: primary
backend:
url: postgresql+asyncpg:///primary
primary: true
pool:
min_size: 5
max_size: 20
- name: reporting
backend:
url: postgresql+asyncpg:///reporting
migration_dir: migrations/reporting
pool:
min_size: 2
max_size: 10

In production, set LEX_SQL__BACKEND__URL via environment variable — never hardcode credentials in YAML. The production validator rejects common default passwords.