5 releases

0.1.0-alpha.4 Aug 29, 2019
0.1.0-alpha.3 Aug 20, 2019
0.1.0-alpha.2 Jul 24, 2019
0.1.0-alpha.1 Jul 15, 2019
0.1.0-alpha.0 Jul 13, 2019

#8 in #heroku

MIT/Apache

7KB
56 lines

dhb-postgres-heroku

Given a DATABASE_URL, it should be dead simple to connect to a Heroku postgres database.

This crate makes it dead simple with rust:

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);

The reason I found the work to create this crate necessary is that connecting to Heroku has 2 quirks.

  1. On the one hand, it requires that we have a secure connection.
  2. On the other hand, it uses self-verified certificates. So we have to enable ssl, but turn off verification.

lib.rs:

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.

  1. On the one hand, it requires that we have a secure connection.
  2. On the other hand, it uses self-verified certificates. So we have to enable ssl, but turn off verification.

Dependencies

~13–22MB
~377K SLoC