From the course: Web APIs in Rust

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Connecting to a database

Connecting to a database - Rust Tutorial

From the course: Web APIs in Rust

Connecting to a database

- [Instructor] This video moves us from flat files through to databases. What we want to do is move away from storing data in text files that we manage manually into an actual database. For our learning purposes, we're going to be using SQLite, but the process that we are using here is also transferable to other databases, such as Postgres or Microsoft SQL Server for example. Let's take a quick look at the architecture that we are going to move into. We'll start with main.rs, which provides the endpoints of our web service. It also has the main function that starts everything up and knits everything together. main.rs calls on auth.rs, which provides authentication via exported functions. The auth module itself hides a lot of implementation details about how that's implemented, but it definitely provides a lot of functionality. It's now going to need to also call on db.rs, or the database module, which exports a Query enum of all valid database queries and the required parameters, but…

Contents