Relational Databases (SQL): MySql, Postgres, SQLite

Learn how to handle other SQL databases with sqlx, the SQL toolkit.

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 SQLSQL DBMS.

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 asyncasync backend must be stated as well, like so:

 sqlx = { version = "0.5.9", features = ["mysql", "runtime-tokio-native-tls"] }

First steps

After we declare the DBMS backend, we can start using sqlx right away:

Get hands-on with 1200+ tech skills courses.