Expand description
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)?;Re-exports§
pub use async_connection::PgAsyncConnection;pub use config::PgConfig;pub use config::SslMode;pub use connection::ConnectionState;pub use connection::PgConnection;pub use connection::TransactionStatusState;pub use types::Format;pub use types::TypeCategory;pub use types::TypeInfo;pub use types::TypeRegistry;
Modules§
- async_
connection - Async PostgreSQL connection implementation.
- auth
- Authentication mechanisms.
- config
- PostgreSQL connection configuration.
- connection
- PostgreSQL connection implementation.
- protocol
- PostgreSQL wire protocol implementation.
- tls
- TLS support for PostgreSQL connections (feature-gated).
- types
- PostgreSQL type system and type conversion.