#postgresql #pool #tokio #async

qp-postgres

快速池:高性能异步泛型池 PostgreSQL 适配器

2 个版本

0.1.1 2022年1月9日
0.1.0 2021年12月6日

#2063数据库接口

MIT 许可协议

24KB
367

PostgreSQL 快速池

高性能异步泛型池 PostgreSQL 适配器

Crates.io Docs.rs Rust Rust GitHub Workflow Crates.io License

使用方法

示例

简单查询

use tokio_postgres::NoTls;

#[tokio::main]
async fn main() {
    let config = "postgresql://postgres:postgres@localhost".parse().unwrap();
    let pool = qp_postgres::connect(config, NoTls, 8);
    let client = pool.acquire().await.unwrap();
    let row = client.query_one("SELECT 1", &[]).await.unwrap();
    let int: i32 = row.get(0);
    dbg!(&int);
}

Web 框架

替代方案

后端 适配器 版本
tokio-postgres bb8-postgres bb8-postgres-version
tokio-postgres deadpool-postgres deadpool-postgres-version
tokio-postgres mobc-postgres mobc-postgres-version
postgres r2d2-postgres r2d2-postgres-version
sqlx - sqlx-version

性能比较

PostgreSQL 总查询时间基准

Benchmark

Benchmark

更多信息,请参阅 Rust 池基准

许可协议

Copyright (c) 2022 Seungjae Park

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

PostgreSQL 快速池 采用 MIT 许可协议

依赖关系

~7–16MB
~232K SLoC