Skip to content
Packages Examples Agents Blog Get started

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: ORI_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 ORI_SQL__BACKEND__URL=postgresql+asyncpg://user:pass@localhost/mydb
export ORI_SQL__POOL__MIN_SIZE=2

KeyTypeDefaultEnv VarDescription
enabledboolTrueORI_SQL__ENABLEDEnable the database module
backendDatabaseBackendConfigsqlite:///piccolina.dbORI_SQL__BACKEND__*Connection URL and driver
poolDatabasePoolConfig(see below)ORI_SQL__POOL__*Connection pool settings
operationsDatabaseOperationConfig(see below)ORI_SQL__OPERATIONS__*Operation settings
outboxDatabaseOutboxConfig(see below)ORI_SQL__OUTBOX__*Outbox pattern settings
migrationsDatabaseMigrationConfig(see below)ORI_SQL__MIGRATIONS__*Migration settings
audit_hmac_keystr | NoneNoneORI_SQL__AUDIT_HMAC_KEYHMAC key for audit signing
backendslist[NamedDatabaseConfig][]ORI_SQL__BACKENDSMulti-database backends

KeyTypeDefaultEnv VarDescription
urlSecretStrrequiredORI_SQL__BACKEND__URLDatabase connection URL

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


KeyTypeDefaultEnv VarDescription
min_sizeint1ORI_SQL__POOL__MIN_SIZEMinimum pool connections
max_sizeint10ORI_SQL__POOL__MAX_SIZEMaximum pool connections
max_overflowint5ORI_SQL__POOL__MAX_OVERFLOWMax overflow connections
recycleint3600ORI_SQL__POOL__RECYCLEConnection recycle time (seconds)
timeoutfloat30.0ORI_SQL__POOL__TIMEOUTPool timeout (seconds)
acquire_timeoutDuration30sORI_SQL__POOL__ACQUIRE_TIMEOUTConnection acquire timeout
idle_timeoutDuration5mORI_SQL__POOL__IDLE_TIMEOUTIdle connection timeout
max_lifetimeDuration1hORI_SQL__POOL__MAX_LIFETIMEMax connection lifetime

KeyTypeDefaultEnv VarDescription
echoboolFalseORI_SQL__OPERATIONS__ECHOLog all SQL statements
statement_timeoutDuration60sORI_SQL__OPERATIONS__STATEMENT_TIMEOUTMax query execution time

KeyTypeDefaultEnv VarDescription
enabledboolTrueORI_SQL__OUTBOX__ENABLEDEnable outbox pattern
poll_intervalDuration5sORI_SQL__OUTBOX__POLL_INTERVALOutbox poll interval
batch_max_ageDuration30sORI_SQL__OUTBOX__BATCH_MAX_AGEMax age for outbox batches

KeyTypeDefaultEnv VarDescription
lock_timeoutDuration30sORI_SQL__MIGRATIONS__LOCK_TIMEOUTMigration lock timeout

KeyTypeDefaultEnv VarDescription
namestrrequiredORI_SQL__BACKENDS__0__NAMEUnique backend name
backendDatabaseBackendConfigrequiredORI_SQL__BACKENDS__0__BACKEND__*Connection config
primaryboolFalseORI_SQL__BACKENDS__0__PRIMARYPrimary backend (unnamed bindings)
poolDatabasePoolConfigmin_size=2ORI_SQL__BACKENDS__0__POOL__*Per-backend pool settings
migration_dirstr | NoneNoneORI_SQL__BACKENDS__0__MIGRATION_DIRAlembic dir for this backend

KeyTypeDefaultDescription
default_page_sizeint20Default pagination page size
max_page_sizeint1000Maximum 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 ORI_SQL__BACKEND__URL=postgresql+asyncpg://user:password@localhost:5432/mydb
export ORI_SQL__POOL__MIN_SIZE=5
export ORI_SQL__POOL__MAX_SIZE=30
export ORI_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 ORI_SQL__BACKEND__URL via environment variable — never hardcode credentials in YAML. The production validator rejects common default passwords.