Rust Diesel Crate Basic Query Example
This is just a quick copy of working code that does a basic database insert and query on a Postgres database from the Diesel crate in Rust.
(All the other tutorails I've seen do a bunch of other unrelated stuff that's hard to parse though)
use PgConnection;
use *;
use posts as posts_table;
use posts;
use dotenv;
use env;
Notes
-
The migration needs to have been run to create the table and the schema.rs file that's auto generated. TODO: document that
# TODO: Add text about this in Cargo.toml
[dependencies]
diesel = { version = "2.0.0", features = ["postgres"] }
dotenvy = "0.15"
~ fin ~