Crate diesel_connection[][src]

Expand description

Static diesel r2d2 connection pooling.

DATABASE_URL env sets postgres database url within connection manager

MAX_DB_CONNECTIONS env sets max postgres connections within connection pool

This library uses booter::boot() to initialize.

  use diesel_connection::{get_connection, PoolError};

  fn main() -> Result<(), PoolError> {

  // Env can be configured before booter::boot giving fine-grain initialization control
  //dotenv().expect("Unable to load .env file");

  // This calls registered initialization functions; i.e. to initialize our pool
  booter::boot();

  let conn = get_connection()?;
  Ok(())
}

Functions

get_connection

Retrieves a connection from the global connection pool.

Type Definitions

Backend
Connection
Pool
PoolError

A re-export of r2d2::Error, which is only used by methods on r2d2::Pool.

PooledConnection