Crate diesel_connection

Crate diesel_connection 

Source
Expand description

Static diesel r2d2 connection pooling with env configuration

Composible connection urls are provided by environment variables using env-url using the DATABASE prefix:

 | ENV                     |                            |
 | -----------------------:|:--------------------------:|
 | DATABASE_URL            | set connection url         |
 | DATABASE_HOST           | set url host               |
 | DATABASE_PORT           | set url port               |
 | DATABASE_PATH           | set selected database      |
 | DATABASE_USERINFO       | set connnection userinfo   |

MAX_DB_CONNECTIONS env sets max connections within connection pool

The dotenv feature flag enables automatic at-most-once dotenv loading via dotenvy. This is necessary because pool statics are initialized pre-main via static_init.

use diesel_connection::{pg::get_connection, PoolError};

#[actix_rt::main]
async fn main() -> Result<(), PoolError> {
  let conn = get_connection()?;
}

Re-exports§

pub use pg::PooledConnection;postgres and non-mysql and non-sqlite

Modules§

mysqlmysql
Types for MySQL connections.
pgpostgres
Types for Postgres connections.
sqlitesqlite
Types for SQLite connections.

Structs§

ConnectionPoolpostgres and non-mysql and non-sqlite
Static connection pool type

Traits§

ConnectionInfo
PoolContext
Trait for defining static connection pool

Functions§

get_connectionpostgres and non-mysql and non-sqlite
Get postgress connection from pool. Use DATABASE_URL env variable to set connection url

Derive Macros§

PoolContext