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


#[actix_rt::main]
async fn main() -> Result<(), PoolError> {
  // Env can be configured before booter::boot giving fine-grain initialization control
  dotenv().expect("Unable to load .env file");
  env_logger::init();
  // This calls registered initialization functions; i.e. to initialize our pool
  booter::boot();
  let conn = get_connection()?;
}

Functions

get_connection

Retrieves a connection from the global connection pool.

Type Definitions

Pool
PoolError

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

PooledConnection