Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Elixir
  3. postgrex

postgrex

Elixirv0.7.0

A PostgreSQL driver for Elixir that uses the binary protocol for efficient data encoding and decoding.

Visit WebsiteGitHubGitHub
1.2k stars312 forks0 contributors

What is postgrex?

Postgrex is a PostgreSQL database driver for the Elixir programming language that provides a robust interface for interacting with PostgreSQL databases. It enables Elixir applications to perform queries, manage transactions, and handle complex data types with high performance and reliability by leveraging PostgreSQL's binary protocol. The driver emphasizes correctness and extensibility, aligning with Elixir's functional programming ethos.

Target Audience

Elixir developers building applications that require efficient and reliable PostgreSQL database interactions, including those needing custom type handling or integration with the Ecto library. It is also suitable for developers working on systems requiring advanced PostgreSQL features like JSON support, arrays, or user-defined types.

Value Proposition

Developers choose Postgrex for its performance through binary protocol support, automatic type conversion between PostgreSQL and Elixir data types, and extensible type system that allows custom extensions. Its integration with DBConnection for transactions and pooling, along with broad PostgreSQL compatibility, makes it a preferred choice over simpler or less feature-complete drivers.

Overview

PostgreSQL driver for Elixir

Use Cases

Best For

  • Building Elixir applications that require high-performance database queries using PostgreSQL's binary protocol for reduced overhead.
  • Handling complex PostgreSQL data types like arrays, hstore, JSON, UUIDs, and custom composite types in Elixir with automatic encoding and decoding.
  • Developing systems needing extensible type support, where custom PostgreSQL types must be mapped to Elixir values via user-defined extensions.
  • Implementing database interactions with transaction management, prepared queries, and connection pooling in Elixir using DBConnection integration.
  • Working with PostgreSQL versions from 8.4 onward, including legacy systems or environments requiring broad compatibility.
  • Integrating JSON data storage and retrieval in PostgreSQL with configurable library support, such as using Jason or alternative JSON libraries.

Not Ideal For

  • Applications using databases other than PostgreSQL, such as MySQL or SQLite, where a dedicated driver is needed.
  • Projects where simple, text-based SQL queries suffice and the binary protocol's performance benefits aren't worth the setup complexity.
  • Teams preferring full ORM abstractions over raw driver usage, as Postgrex is low-level and requires manual query handling.
  • Environments with strict CI/CD pipelines where recompilation for JSON library changes causes deployment delays.

Pros & Cons

Pros

Efficient Binary Protocol

Uses PostgreSQL's binary protocol for data encoding, reducing overhead compared to text-based protocols and improving performance, as stated in the README's key features.

Comprehensive Type Mapping

Automatically decodes and encodes common PostgreSQL types like integers, dates, and UUIDs into Elixir values, simplifying data handling with built-in support.

Extensible Type System

Allows user-defined extensions for custom or unsupported PostgreSQL types, enabling flexibility for complex data types, demonstrated in the extensions directory.

Robust Transaction Support

Integrates with DBConnection for transactions, prepared queries, and connection pooling, ensuring reliable database interaction management.

JSON Library Flexibility

Supports JSON via Jason with configurable alternatives, though recompilation is required for changes, offering adaptability in JSON handling.

Cons

OID Type Handling Complexity

OID types require explicit casting or integer handling instead of automatic text conversion, adding boilerplate code and potential errors, as noted in the README.

PgBouncer Limitations

Older PgBouncer versions (pre-1.21.0) don't support named prepared statements, forcing unnamed queries that can impact performance or require extra configuration.

JSON Configuration Rigidity

Changing the JSON library requires cleaning and recompiling Postgrex with mix deps.clean, which can disrupt development workflows and deployment processes.

Legacy Feature Gaps

Features like hstore are not supported on PostgreSQL 8.4, limiting compatibility for systems using very old database versions, as mentioned in the README.

Frequently Asked Questions

Quick Stats

Stars1,212
Forks312
Contributors0
Open Issues5
Last commit24 days ago
CreatedSince 2013

Tags

#database-driver#binary-protocol#elixir#open-source#ecto#postgresql#data-encoding#type-conversion

Built With

E
Elixir
J
Jason

Links & Resources

Website

Included in

Elixir13.1kPostgreSQL11.8k
Auto-fetched 21 hours ago

Related Projects

PostgreSQLPostgreSQL

PostgreSQL client for node.js.

Stars13,219
Forks1,357
Last commit5 days ago
pqpq

Go PostgreSQL driver for database/sql

Stars9,966
Forks972
Last commit1 month ago
ectoecto

A toolkit for data mapping and language integrated query.

Stars6,498
Forks1,485
Last commit8 days ago
rust-postgresqlrust-postgresql

Native PostgreSQL driver for the Rust programming language

Stars4,005
Forks590
Last commit3 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub