Skip to content

Latest commit

 

History

History
43 lines (28 loc) · 889 Bytes

README.md

File metadata and controls

43 lines (28 loc) · 889 Bytes

rust-diesel-examples

Rust Diesel PostgreSQL examples

When I used Diesel with PostgreSQL for the first time, I faced with the lack of complete working code examples. Here I have tried to assemble some convenient example use-cases in one place.

Setup

Install diesel cli:

cargo install diesel_cli --no-default-features --features postgres

Set URL to database

export DATABASE_URL=postgres://<postgres_username>:<postgres_password>@<postgres_host>:<postgres_port>/school

Perform migrations. At this step Rust schema is also automatically generated and printed to the file defined in diesel.toml

diesel setup
diesel migration run

Execute

Put database in vanilla state

diesel migration redo

Run example binary that will query, insert and update tables

cargo run

Tables diagram

alt text