Expand description
§dhb-heroku-postgres
Given a DATABASE_URL, it should be dead simple to connect to a Heroku postgres database.
This crate makes it dead simple:
You pass a DATABASE_URL to the postgres_client function and get a working client back, as in
let mut client = get_client(&database_url);
If you want a connection pool, you’ll also want to pass in a maximum number of connections.
let max_size = 20;
let mut pool = get_pool(&database_url, max_size);
The reason I found the work to create this crate useful is that connecting to Heroku postgres has 2 quirks.
- On the one hand, it requires that we have a secure connection.
- On the other hand, it uses self-verified certificates. So we have to enable ssl, but turn off verification.
Re-exports§
pub use postgres;
pub use r2d2;
pub use r2d2_postgres;
Structs§
- A synchronous PostgreSQL client.
Functions§
- Get a working client from a postgres url.
- This function demonstrates how to get a HerokuPooledConnection from a HerokuPool.
- Get a heroku-capable r2d2 connection pool from a postgres url and a maximum size.
- Try out a client by running through a set of postgres commands to create a table, insert a row, read the row, and drop the table.
Type Aliases§
- This type is defined so that you can pass around a connection after obtaining it from a connection pool.