Non-blocking PostgreSQL client for Node.js, with a pure JavaScript driver and optional native libpq bindings.
jackc/pgx
A pure Go driver and toolkit for PostgreSQL, exposing PostgreSQL-specific features like LISTEN/NOTIFY and COPY.
- Stars
- 14,384
- Forks
- 1,159
- Open issues
- 218
- Last commit
- 2 days ago
What is it?
pgx is a pure Go driver and toolkit for PostgreSQL. Its driver interface is low-level and aimed at performance, and it exposes PostgreSQL-specific features such as LISTEN / NOTIFY and COPY. An adapter for the standard database/sql interface is also included for code that already depends on it.
The toolkit side is a set of packages that implement PostgreSQL functionality such as wire protocol parsing and type mapping between PostgreSQL and Go. These can be reused to build alternative drivers, proxies, load balancers, or logical replication clients. A connection pool (pgxpool) is provided for concurrent use.
The project supports roughly 70 PostgreSQL types, prepared statement caching, batch queries, binary format encoding for custom types, and tracing and logging hooks. It targets Go 1.25 and later and PostgreSQL 14 and later.
Key features
- 01Supports roughly 70 PostgreSQL types with type mapping to Go
- 02Automatic prepared statement caching and batch queries
- 03COPY protocol support for bulk data loading
- 04LISTEN / NOTIFY and large object support
- 05Connection pool with an after-connect hook
- 06Tracing and logging hooks, plus a database/sql adapter
Use cases
- Building Go services that talk directly to PostgreSQL and need its specific features
- Bulk-loading large datasets with the COPY protocol
- Writing a PostgreSQL proxy, connection pooler, or logical replication client
- Using pgx in an existing codebase that relies on database/sql
Quick start
- 1
Install the pgx v5 module with Go
go get github.com/jackc/pgx/v5 - 2
Write a program that connects with pgx.Connect using a DATABASE_URL environment variable and runs a query
Things to know
- Requires a PostgreSQL server (versions 14 and higher are supported) to connect to.
- Requires Go 1.25 or higher.
In collections
Topics
FAQ
- What is pgx?
- A pure Go driver and toolkit for PostgreSQL, exposing PostgreSQL-specific features like LISTEN/NOTIFY and COPY. pgx is a pure Go driver and toolkit for PostgreSQL. Its driver interface is low-level and aimed at performance, and it exposes PostgreSQL-specific features such as LISTEN / NOTIFY and COPY. An adapter for the standard database/sql interface is also included for code that already depends on it.
- Is pgx free to use? What license does it have?
- pgx is open source under the MIT license. Check the license terms before using it in commercial products.
- Is pgx still maintained?
- Actively maintained. The last commit to pgx was on Nov 5, 2026.
- What can I use pgx for?
- Building Go services that talk directly to PostgreSQL and need its specific features Bulk-loading large datasets with the COPY protocol Writing a PostgreSQL proxy, connection pooler, or logical replication client Using pgx in an existing codebase that relies on database/sql
- How do I install pgx?
- Install the pgx v5 module with Go: go get github.com/jackc/pgx/v5 Write a program that connects with pgx.Connect using a DATABASE_URL environment variable and runs a query
- Where can I get pgx?
- The source code and installation instructions are on GitHub: https://github.com/jackc/pgx
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
The official-style Type 4 JDBC driver that lets Java programs connect to and query PostgreSQL databases.
Async, pure Rust SQL toolkit with compile-time checked queries written as plain SQL, supporting PostgreSQL, MySQL/MariaDB, and SQLite.
Go-based database migration tool with a CLI and library for applying ordered schema changes across many databases.
A CLI and Go library for managing database schema changes through versioned SQL files or Go functions.
Free multi-platform desktop SQL client and database tool supporting 100+ databases via JDBC and ODBC drivers.