chore: update dependencies

This commit is contained in:
Ryan Leckey
2020-06-21 03:55:05 -07:00
parent 4448c0e629
commit 7c4c185698
3 changed files with 131 additions and 86 deletions

View File

@@ -1,4 +1,4 @@
use sqlx::{database::Database, Connect};
use sqlx::{database::Database, Connect, Pool};
use std::env;
fn setup_if_needed() {
@@ -17,6 +17,25 @@ where
Ok(DB::Connection::connect(&env::var("DATABASE_URL")?).await?)
}
// Make a new pool
// Ensure [dotenv] and [env_logger] have been setup
pub async fn pool<DB>() -> anyhow::Result<Pool<DB>>
where
DB: Database,
{
setup_if_needed();
let pool = Pool::<DB>::builder()
.min_size(0)
.max_size(5)
.test_on_acquire(true)
.build(&env::var("DATABASE_URL")?)
.await?;
Ok(pool)
}
// Test type encoding and decoding
#[macro_export]
macro_rules! test_type {