5 releases (3 breaking)
0.4.0 | Mar 31, 2022 |
---|---|
0.3.0 | Jun 25, 2021 |
0.2.0 | Mar 25, 2021 |
0.1.1 | Jul 13, 2020 |
0.1.0 | Feb 27, 2020 |
#2271 in Asynchronous
9KB
158 lines
actix-postgres
PostgreSQL integration for Actix framework.
Features
- Postgresql Connection
Examples
use actix::prelude::*;
use actix_postgres::{bb8_postgres::tokio_postgres::tls::NoTls, PostgresActor, PostgresMessage};
#[actix_rt::main]
async fn main() {
let path = std::env::var("PG_PATH").unwrap();
let pg_actor = PostgresActor::start(&path, NoTls).unwrap();
let task = PostgresMessage::new(|pool| {
Box::pin(async move {
let connection = pool.get().await?;
connection
.query("SELECT NOW()::TEXT as c", &vec![])
.await
.map_err(|err| err.into())
})
});
let res = pg_actor.send(task).await.unwrap().unwrap();
let val: &str = res[0].get(0);
println!("{}", val);
System::current().stop();
}
lib.rs
:
PostgreSQL integration for Actix framework.
Dependencies
~8–17MB
~244K SLoC