qail-pg
PostgreSQL driver for QAIL - native wire protocol
A high-performance PostgreSQL driver that speaks the wire protocol directly. No SQL strings, no SQL injection - just pure AST-to-wire encoding.
Features
- AST-Native - Compiles QAIL AST directly to PostgreSQL wire protocol
- 28% Faster - Benchmarked at 1.36M rows/s COPY (vs asyncpg at 1.06M rows/s)
- Query Pipelining - 24x faster batch operations via
pipeline_batch() - SSL/TLS - Production-ready with
tokio-rustls - SCRAM-SHA-256 - Secure password authentication
- Connection Pooling - Built-in
PgPool - Transactions - Full
begin/commit/rollbacksupport
Installation
[]
= "0.9"
= "0.9"
Quick Start
use ;
use PgDriver;
async
High-Performance Batch Operations
// Execute 10,000 queries in a single network round-trip
let cmds: =
.map.collect;
let count = driver.pipeline_batch.await?;
println!;
COPY Protocol (Bulk Insert)
use CopyEncoder;
// Build COPY data
let mut encoder = new;
for i in 0..1_000_000
// Execute COPY
driver.copy_bulk_bytes.await?;
Connection Pooling
use PgPool;
// Create a pool with 10 connections
let pool = new.await?;
// Acquire a connection
let mut conn = pool.acquire.await?;
let rows = conn.fetch_all.await?;
SSL/TLS Support
qail-pg uses tokio-rustls for TLS connections:
// SSL is auto-negotiated during connection
let driver = connect_with_password.await?;
Ergonomic Expression Builders
qail-pg works seamlessly with qail-core's ergonomic builders:
use *;
// COUNT(*) FILTER (WHERE condition)
count_filter.alias
// NOW() - INTERVAL '24 hours'
now_minus
// CASE WHEN ... ELSE ... END
case_when
.otherwise
.alias
// Type casting
cast
Type Support
| PostgreSQL Type | Rust Type |
|---|---|
text, varchar |
String |
int4, int8 |
i32, i64 |
float8 |
f64 |
bool |
bool |
uuid |
uuid::Uuid |
jsonb |
serde_json::Value |
timestamp |
chrono::DateTime<Utc> |
date |
chrono::NaiveDate |
numeric |
rust_decimal::Decimal |
License
MIT