5个版本 (3个重大更新)
0.4.0 | 2022年3月31日 |
---|---|
0.3.0 | 2021年6月25日 |
0.2.0 | 2021年3月25日 |
0.1.1 | 2020年7月13日 |
0.1.0 | 2020年2月27日 |
#1175 in 异步
每月下载 34次
9KB
158 行
actix-postgres
Actix框架的PostgreSQL集成。
特性
- Postgresql连接
示例
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
:
Actix框架的PostgreSQL集成。
依赖
~8–18MB
~254K SLoC