📄️ Working with Databases in Rust
In this module, you'll learn how to work with relational databases in Rust using the SQLx library with PostgreSQL. For you as a .NET developer, this is comparable to using Entity Framework or Dapper, but with Rust's type safety and performance advantages. You'll also learn about error handling patterns in Rust.
📄️ Introduction to SQLx
SQLx is a Rust library that provides type-safe database interactions without an ORM. Key features include:
📄️ Error Handling
This code introduces two important Rust error handling patterns:
📄️ SQL Queries
SQLx provides several ways to execute queries. The most powerful is the query! macro, which validates your SQL at compile time:
📄️ Database Migrations
SQLx provides a CLI tool for managing database migrations. To use it:
📄️ Configuration
For almost any database you'll work with, you need to provide some kind of connection string. Which brings us on to the topic of application configuration. What's the best way to pass custom configuration to your application?
📄️ Challenge
Now it's time to apply what you've learned about database access with SQLx! In this module's challenge, you'll: