SQLx is an awesome crate for interacting with databases in Rust with compile time checks. In this blog post, we will learn how to use it in an Axum backend to store and retrieve data from a database.
The example will be storing submitted contact forms from the previous post about Axum.
During the SQLx integration, we will learn about states and returning JSON in Axum.
SQLx is an async Rust crate that let's us interact with a database with compile-time checked queries 🧰
This post will be a short introduction to SQLx with PostgreSQL, but SQLx also supports MySQL, SQLite, and MSSQL.
The example will be a todo list in a database. A classical programming example, I know 😅
We will also see if SQLx protects us against SQL injections 💉