lref-provider-postgres
PostgreSQL database provider for Rust Entity Framework (lref).
Implements DatabaseProvider, SqlGenerator, and AsyncConnection traits for PostgreSQL using deadpool-postgres for connection pooling.
Features
- Connection pooling via
deadpool-postgres - PostgreSQL-native parameterized queries (
$1,$2, ...) - Double-quoted identifier quoting (
"table_name") RETURNING *support for INSERT auto-increment backfillSERIAL/BIGSERIALtype mapping for auto-increment columns- Full CRUD:
execute(),query(), transactions - Database introspection (
information_schema.columns+table_constraints)
Quick Start
[]
= "0.1"
= "0.1"
= { = "1", = ["full"] }
use DatabaseProvider;
use PostgresProvider;
use Arc;
let provider = new;
// Get a connection
let mut conn = provider.get_connection.await?;
// Execute parameterized query
conn.execute.await?;
// Query rows
let rows = conn.query.await?;
Type Mapping
| Rust Type | PostgreSQL Type |
|---|---|
i16 |
SMALLINT / SMALLSERIAL |
i32 |
INTEGER / SERIAL |
i64 |
BIGINT / BIGSERIAL |
f32 |
REAL |
f64 |
DOUBLE PRECISION |
bool |
BOOLEAN |
String |
TEXT / VARCHAR(n) |
Vec<u8> |
BYTEA |
Database Introspection
use introspect_postgres;
let tables = introspect_postgres.await?;
for table in &tables
SQL Dialect
- Placeholders:
$1,$2, ... (positional) - Identifiers:
"table_name"(double-quote) - Pagination:
OFFSET N LIMIT M - Auto-increment:
SERIAL
License
MIT - ?see LICENSE