A native, non-blocking PostgreSQL driver for the Crystal programming language.
crystal-pg is a PostgreSQL database driver for the Crystal programming language. It implements the PostgreSQL wire protocol natively in Crystal, providing non-blocking database access while supporting PostgreSQL-specific features like LISTEN/NOTIFY, advanced data types, and configurable authentication methods. It solves the need for a high-performance, fully-featured PostgreSQL client in Crystal's ecosystem.
Crystal developers building applications that require PostgreSQL database connectivity, especially those needing PostgreSQL-specific features or optimal performance in concurrent environments.
Developers choose crystal-pg because it's the standard, most feature-complete PostgreSQL driver for Crystal—offering native non-blocking I/O, extensive PostgreSQL protocol support, and seamless integration with Crystal's database API while maintaining security best practices.
a postgres driver for crystal
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses Crystal's fiber-based concurrency for efficient, non-blocking database operations, ideal for high-performance concurrent applications as highlighted in the README.
Supports advanced PostgreSQL capabilities like LISTEN/NOTIFY and specialized data types such as geometric types and intervals, going beyond the standard crystal-db API.
Disables cleartext authentication by default to prevent downgrade attacks, with configurable methods like scram-sha-256 and md5 for flexibility while maintaining security.
Maps PostgreSQL types like JSONB, UUID, and arrays to Crystal types with precision preservation, though numeric and interval types require additional handling.
PostgreSQL's numeric type requires casting to float for math or depends on LibGMP for arbitrary precision via pg_ext/big_rational, adding setup and dependency overhead.
Intervals are not directly mapped to Crystal's built-in time types, necessitating the use of PG::Interval and manual conversions, which can be cumbersome.
As a PostgreSQL-specific driver, it ties applications to PostgreSQL, making database migration or interoperability with other databases more difficult.
While cleartext is disabled by default, its availability as an option poses potential security vulnerabilities if misconfigured, as warned in the README.