deadpool-aykroyd

Crates.iodeadpool-aykroyd
lib.rsdeadpool-aykroyd
version0.3.1
sourcesrc
created_at2023-12-15 18:47:17.990559
updated_at2024-02-20 17:48:14.893577
descriptionAykroyd micro-ORM for the deadpool connection pool.
homepage
repositoryhttps://git.sr.ht/~couch/aykroyd
max_upload_size
id1071190
size6,323
Andrew Dona-Couch -- GitHub drop ICE (couchand)

documentation

https://docs.rs/deadpool-aykroyd/latest/deadpool_aykroyd/

README

deadpool-aykroyd

Documentation

aykroyd support library for the deadpool connection pool.

Example

use deadpool_aykroyd::{Manager, ManagerConfig, Pool, RecyclingMethod};
use tokio_postgres::NoTls;

#[derive(aykroyd::QueryOne)]
#[query(row(Row), text = "SELECT 1 + $1")]
struct AddOneTo(i32);

#[derive(aykroyd::FromRow)]
struct Row(i32);

#[tokio::main]
async fn main() {
    let pg_config = "host=localhost user=postgres".parse().unwrap();
    let mgr_config = ManagerConfig {
        recycling_method: RecyclingMethod::Fast
    };
    let mgr = Manager::from_config(pg_config, NoTls, mgr_config);
    let pool = Pool::builder(mgr).max_size(16).build().unwrap();
    for i in 1..10 {
        let mut client = pool.get().await.unwrap();
        let stmt = client.prepare_cached("SELECT 1 + $1").await.unwrap();
        let row = client.query_onw(&AddOneTo(i)).await.unwrap();
        let value = row.0;
        assert_eq!(value, i + 1);
    }
}
Commit count: 0

cargo fmt