Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Database Support

Ferriorm supports PostgreSQL and SQLite. Support is controlled by Cargo feature flags on the ferriorm-runtime crate.

Feature Matrix

FeaturePostgreSQLSQLite
Connection
Connection poolingYesYes
PoolConfigYesYes
Auto-detection from URLYesYes
CRUD
create / find / update / deleteYesYes
create_many / update_many / delete_manyYesYes
countYesYes
Filtering
StringFilter (equals, contains, etc.)YesYes
IntFilter / BigIntFilter / FloatFilterYesYes
BoolFilterYesYes
DateTimeFilterYesYes
EnumFilterYesYes
AND / OR / NOT combinatorsYesYes
Case-insensitive mode (QueryMode)Yes (ILIKE)Partial (LIKE is case-insensitive for ASCII in SQLite)
Ordering & Pagination
ORDER BYYesYes
LIMIT / OFFSETYesYes
Relations
Include (batched loading)YesYes
Foreign keysYesYes (if enabled)
Select
Partial column selectionYesYes
Aggregates
MIN / MAXYesYes
AVG / SUMYesYes
Raw SQL
raw_fetch_all / one / optionalYesYes
raw_executeYesYes
Direct pool accessYes (pg_pool())Yes (sqlite_pool())
Transactions
run_transactionYesYes
Auto-rollback on errorYesYes
Migrations
migrate dev (shadow DB)YesYes
migrate dev (snapshot)YesYes
migrate deployYesYes
migrate statusYesYes
db pull (introspection)YesYes
Schema Features
@idYesYes
@uniqueYesYes
@default(uuid())YesYes
@default(now())YesYes
@default(autoincrement())YesYes
@updatedAtYesYes
@relationYesYes
@@indexYesYes
@@unique (composite)YesYes
@@mapYesYes
Enums (native)Yes (CREATE TYPE)Emulated (TEXT + CHECK)

URL Formats

PostgreSQL

postgres://user:password@host:port/database
postgresql://user:password@host:port/database

Options can be appended as query parameters:

postgres://user:pass@host/db?sslmode=require

SQLite

sqlite:path/to/database.db
sqlite::memory:
file:path/to/database.db
path/to/database.db

SQLite URLs support query parameters for pragmas:

sqlite:mydb.db?mode=rwc

Type Mapping

PostgreSQL

Schema typeRust typePostgreSQL type
StringStringTEXT
Inti32INTEGER
BigInti64BIGINT
Floatf64DOUBLE PRECISION
BooleanboolBOOLEAN
DateTimechrono::DateTime<Utc>TIMESTAMPTZ
enum FooFoo (generated)Custom enum type

SQLite

Schema typeRust typeSQLite type
StringStringTEXT
Inti32INTEGER
BigInti64INTEGER
Floatf64REAL
BooleanboolBOOLEAN
DateTimechrono::DateTime<Utc>TEXT (ISO 8601)
enum FooFoo (generated)TEXT

SQLite DateTime Handling

SQLite’s CURRENT_TIMESTAMP produces values in the format YYYY-MM-DD HH:MM:SS (without timezone). The sqlx chrono integration parses these values correctly, treating them as UTC. This means @default(now()) works as expected on SQLite – the value is stored as a TEXT column in ISO-like format and deserialized into chrono::DateTime<Utc> by sqlx.

Note that @default(uuid()) and @default(cuid()) do not produce SQL-level defaults on SQLite. The UUID/CUID values are generated in Rust application code before the INSERT statement is executed, so the column will always receive a value from the application.

Known Limitations

LimitationAffects
No nested includesBoth
No raw SQL bind helpers (use sqlx directly)Both
Enum columns stored as TEXTSQLite
No array/JSON column typesBoth
No database viewsBoth
No stored proceduresBoth