Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wpcodevo/rust-axum-mysql

In this article, you'll discover how to use the Axum framework to build a RESTful API in Rust that supports basic CRUD (Create, Read, Update, Delete) operations against a MySQL database.
https://github.com/wpcodevo/rust-axum-mysql

axum axum-framework crud crud-api docker mysql-database rust sqlx sqlx-cli

Last synced: 2 months ago
JSON representation

In this article, you'll discover how to use the Axum framework to build a RESTful API in Rust that supports basic CRUD (Create, Read, Update, Delete) operations against a MySQL database.

Awesome Lists containing this project

README

        

# Rust CRUD API Example with Axum Framework and MySQL

In this article, you'll discover how to use the Axum framework to build a RESTful API in Rust that supports basic CRUD (Create, Read, Update, Delete) operations against a MySQL database. To achieve this, we'll be leveraging the SQLx toolkit, which provides a simple and efficient way to interact with databases.

![Rust CRUD API Example with Axum Framework and MySQL](https://codevoweb.com/wp-content/uploads/2023/04/Rust-CRUD-API-Example-with-Axum-Framework-and-MySQL.webp)

## Topics Covered

- Set up and Run the Axum MySQL CRUD API Project
- Run the Axum CRUD API with a Frontend App
- Set up the Rust Project
- Set up the MySQL Server with Docker
- Connect the Axum Server to the MySQL Server
- Perform Database Migrations
- Define the SQLX Database Model
- Define the API Request Structs
- Implement the CRUD Functionalities
- Route Function to Fetch All Records
- Route Function to Insert a Record
- Route Function to Retrieve a Record
- Route Function to Edit a Record
- Route Function to Delete a Record
- The Complete Code of the Route Functions
- Create an Axum Router for the Route Functions
- Register the Axum Router and Set up CORS
- Conclusion

Read the entire article here: [https://codevoweb.com/rust-crud-api-example-with-axum-framework-and-mysql/](https://codevoweb.com/rust-crud-api-example-with-axum-framework-and-mysql/)