2 unstable releases
Uses new Rust 2024
| 0.2.0 | Feb 15, 2026 |
|---|---|
| 0.1.1 | Feb 5, 2026 |
#2977 in Database interfaces
755KB
17K
SLoC
PostgreSQL driver for SQLModel Rust.
sqlmodel-postgres is the Postgres driver for the SQLModel ecosystem. It
implements the PostgreSQL wire protocol from scratch using asupersync's TCP
primitives and exposes a Connection implementation for query execution.
Role In The Architecture
- Implements
sqlmodel-core::Connectionfor Postgres - Provides authentication, protocol framing, and type conversions
- Powers
sqlmodel-queryexecution andsqlmodel-sessionpersistence
This crate implements the PostgreSQL wire protocol from scratch using asupersync's TCP primitives. It provides:
- Message framing and parsing
- Authentication (cleartext, MD5, SCRAM-SHA-256)
- Simple and extended query protocols
- Connection management with state machine
- Type conversion between Rust and PostgreSQL types
Type System
The types module provides comprehensive type mapping between PostgreSQL
and Rust types, including:
- OID constants for all built-in types
- Text and binary encoding/decoding
- Type registry for runtime type lookup
Example
use sqlmodel_postgres::{PgConfig, PgConnection};
let config = PgConfig::new()
.host("localhost")
.port(5432)
.user("postgres")
.database("mydb");
let conn = PgConnection::connect(config)?;
sqlmodel-postgres
PostgreSQL driver implementing the SQLModel Connection trait.
Role in the SQLModel Rust System
- Implements the Postgres wire protocol with asupersync I/O.
- Provides authentication, query, and type conversion support.
- Used by sqlmodel-query and sqlmodel-session at runtime.
Usage
Most users should depend on sqlmodel and import from sqlmodel::prelude::*.
Use this crate directly if you are extending internals or building tooling around the core APIs.
Links
Dependencies
~29–48MB
~771K SLoC