A native PostgreSQL driver for Zig with connection pooling, prepared statements, and LISTEN/NOTIFY support.
pg.zig is a native PostgreSQL driver for the Zig programming language, enabling Zig applications to connect to and query PostgreSQL databases. It solves the need for a type-safe, efficient database client in Zig's ecosystem, offering features like connection pooling, prepared statements, and real-time notifications.
Zig developers building applications that require database interactions with PostgreSQL, particularly those needing performance, type safety, and advanced features like connection pooling or pub/sub.
Developers choose pg.zig for its strict type safety, native Zig integration, and comprehensive feature set including pooling and LISTEN/NOTIFY, all while maintaining high performance and correctness.
Native PostgreSQL driver / client for Zig
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enforces precise type mappings, such as requiring i16 for smallint columns, preventing runtime errors and enhancing correctness as documented in the type support section.
Provides configurable pooling with features like eager initialization and background reconnection, improving resource management for concurrent applications, as shown in the Pool init options.
Offers unsafe fast modes that skip runtime checks for critical loops and allows tuning of read/write buffers, enabling high-throughput scenarios in performance-sensitive code.
Supports LISTEN/NOTIFY for real-time communication, prepared statement caching, and Prometheus-compatible metrics, making it suitable for complex, event-driven applications.
TLS is marked as experimental and requires OpenSSL configuration, which might be unstable or incomplete for production use in secure environments, as admitted in the README.
Due to Zig's lack of error payloads, error handling is described as 'not great,' requiring checks on conn.err and making it less ergonomic for detailed error management.
Caching has caveats with connection poolers and requires careful per-connection management, which can be error-prone and less intuitive, as highlighted in the caching section.