Relational Databases (SQL): MySql, Postgres, SQLite
Explore how to use the sqlx crate in Rust to connect with multiple SQL databases including MySQL, Postgres, and SQLite. Understand connecting, executing queries, binding Rust variables, and retrieving data with practical examples.
We'll cover the following...
We'll cover the following...
Sqlx: The SQL toolkit
Working with a specific database is all well and good, but what if we want to have the option of choosing which back-end database to use? That’s where we can use sqlx, a crate that helps us interface with many different
At the moment, sqlx supports the following types of databases:
- MySQL/MariaDB
- Postgres
- SQLite
- MSSQL
The support must be stated as a feature when loading the crate in our Cargo.toml. The
sqlx = { version = "0.5.9", features = ["mysql", "runtime-tokio-native-tls"] }