Connecting to PostgreSQL with Diesel
Now that our database is running, we will build a connection to this database in this section. To do this, we will be using the diesel
crate. The diesel
crate enables us to get our Rust code to connect to databases. We are using the diesel
crate instead of other crates because the diesel
crate is the most established, having a lot of support and documentation. To do this, let us go through the following steps:
- First, we will utilize the
diesel
crate. To do this, we can add the following dependencies in ourcargo.toml
file:diesel = { version = "1.4.8", features = ["postgres",
"chrono",
...