January 2019
Intermediate to advanced
520 pages
14h 32m
English
To create a connection pool, we will use the r2d2 crate that can hold multiple connections and provide one for us from the pool. This crate is generic, so you'll need a specific implementation for every database to connect to it. The r2d2 crate can connect to the following databases using adapter crates:
For our example, we need the r2d2-postgres adapter crate to connect to the PostgreSQL database. Add it to our dependencies with the r2d2 crate:
[dependencies]clap = "2.32"csv = "1.0"failure = "0.1"postgres = "0.15"r2d2 = "0.8"r2d2_postgres = "0.14"rayon = "1.0"serde = "1.0"serde_derive = "1.0"
We also keep the postgres dependency, and add failure for error-handling ...
Read now
Unlock full access