This project is a simple CRUD (Create, Read, Update, Delete) API built using the Actix Web framework, SQLx and PostgreSQL as the database.
- Rust (latest stable version)
- PostgreSQL
- Cargo (Rust package manager)
git clone https://github.com/singgihpr/actix_simple_crud_postgres.git
cd actix_simple_crud_postgres
- Install PostgreSQL and start the service.
- Create a new database:
psql -U postgres
CREATE DATABASE rust_crud_postgres;
- Set up the database schema:
psql -U postgres -d rust_crud_postgres -f schema.sql
Create a .env
file in the root directory and add the following:
DATABASE_URL=postgres://username:password@localhost/rust_crud_postgres
Replace username
and password
with your PostgreSQL credentials.
cargo build
cargo run
The server will start at http://localhost:8080
.
GET /users
- Retrieve all usersGET /users/{id}
- Retrieve an users by IDPOST /users
- Create a new usersPATCH /users/{id}
- Update an users by IDDELETE /users/{id}
- Delete an users by ID
This project is licensed under the MIT License.