Skip to main content
Use SQLx 0.9 and Tokio with SQLite, PostgreSQL or MySQL. Enable sqlite for bundled SQLite, postgres for PostgreSQL, or mysql for MySQL. Each driver enables the shared sqlx integration. Server drivers enable Rustls TLS support and have no SQLite dependency:
Derive Model and SqlModel together. Model supplies JSON/Serde/schema/validation behavior; SqlModel adds table metadata, a validated SQLx FromRow implementation, and asynchronous persistence operations. Each table has one primary key and uses a concrete owned struct with named fields. SQLx is re-exported through rydantic::sqlx. SQL identifiers are checked at compile time and quoted in generated statements. CRUD and filter values use bound parameters. Column metadata is exposed as User::COLUMNS; create_table_sql::<DB>() and create_index_sql::<DB>() expose generated DDL for an explicit driver. Continue with PostgreSQL and MySQL, queries and transactions, or automatic migrations.