ricardodarocha / sqlxpg

This is a very interesting project connecting Postgres Database with SQLX Rust crate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Template Rust Api + Postgres

I would like to share with you a tiny preconfigured template to create amazing apis with Rust, using routes, json and so on.

api_folder\
|- main.rs
|- routes.rs
|- models.rs

Installation

First check you have already Rust installed.
Clone this repositorio Git
Run cargo check cargo run

git clone https://github.com/ricardodarocha/sqlxpg.git
cd sqlxpg 
cargo run

Navigate to

GET localhost:8089/user

Note: Check the compatible type to Rust + Postgre

Summary

This server is preconfigured in port 8089
This server has the following routes /ping
/pong
/user
/post_user

https://github.com/ricardodarocha/sqlxpg/blob/master/src/api/routes.rs

The Postgre database connection is seted in https://github.com/ricardodarocha/sqlxpg/blob/master/src/main.rs

Models

Models represent the struct of sql, tables em views https://github.com/ricardodarocha/sqlxpg/blob/master/src/model/usermodel.rs

The models implemments FromRow do serialization

About

This is a very interesting project connecting Postgres Database with SQLX Rust crate


Languages

Language:Rust 100.0%