use bb8::Pool;
use bb8_postgres::PostgresConnectionManager;
use std::str::FromStr;
#[tokio::main]
async fn main() {
let config = tokio_postgres::config::Config::from_str(
"postgresql://postgres:mysecretpassword@localhost:5432",
)
.unwrap();
let pg_mgr = PostgresConnectionManager::new(config, tokio_postgres::NoTls);
let pool = match Pool::builder().build(pg_mgr).await {
Ok(pool) => pool,
Err(e) => panic!("builder error: {e:?}"),
};
let connection = pool.get().await.unwrap();
let select = connection.prepare("SELECT 1").await.unwrap();
let row = connection.query_one(&select, &[]).await.unwrap();
println!("result: {}", row.get::<usize, i32>(0));
}