Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/wpcodevo/rust-axum-mysql
- Owner: wpcodevo
- Created: 2023-04-17T16:17:26.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-27T09:40:08.000Z (about 1 year ago)
- Last Synced: 2024-05-15T15:32:46.707Z (9 months ago)
- Topics: axum, axum-framework, crud, crud-api, docker, mysql-database, rust, sqlx, sqlx-cli
- Language: Rust
- Homepage: https://codevoweb.com/rust-crud-api-example-with-axum-framework-and-mysql/
- Size: 27.3 KB
- Stars: 22
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
- ConclusionRead 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/)