Connecting to a Database
sqlx pools.
What is sqlx?
sqlx is an async, pure-Rust SQL toolkit. It is not an ORM; you write real SQL but get compile-time checking and type-safe results.
- Supports Postgres, MySQL, SQLite
- Built on async runtimes like Tokio
Adding sqlx
Declare sqlx with the runtime and database features you need. This edits Cargo.toml and runs in your terminal.
[dependencies]
sqlx = { version = "0.7", features = ["runtime-tokio", "postgres"] }
tokio = { version = "1", features = ["full"] }All lessons in this course
- Connecting to a Database
- Compile-Time Checked Queries
- CRUD Operations
- Migrations