# pg

> The Ruby interface to PostgreSQL

Source: https://talira.ai/catalog/pg-z86bax29
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [libraries / databases / drivers](https://talira.ai/categories/libraries/databases/drivers)
- Licence: BSD-2-Clause OR Ruby[^1][^2]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Backed by: [ruby-pg maintainers](https://talira.ai/orgs/ruby-pg-maintainers.md)

pg is the Ruby interface to [PostgreSQL](https://talira.ai/catalog/postgresql-cm55wcnd.md), working with PostgreSQL 10 and later and Ruby 3.1 or newer. It wraps libpq: you connect with PG.connect, run queries through PG::Connection and read rows from PG::Result. Its binary gems bundle libpq, so they don't need the system's PostgreSQL client libraries; the source gem builds against libpq's headers. It's maintained by Michael Granger and Lars Kanis, under the 2-clause BSD licence or Ruby's own terms.

## Links

- GitHub: https://github.com/ged/ruby-pg
- Docs: https://deveiate.org/code/pg/

## Problems it solves

- connect my Ruby app to a PostgreSQL database
- run SQL queries against Postgres from a Ruby script
- use PostgreSQL as the database for my Rails app

## Features

- connect to PostgreSQL and run queries from Ruby
- binary gems that bundle libpq
- works with PostgreSQL 10 and later

## Trust

Overall: 0.61 out of 1.
Signals: maintenance 1.00, adoption 0.59, momentum 0.24, community 0.75, backing 0.30, extensibility 0.00.

- last commit 16 days ago
- 70 commits in the last 90 days
- 872 GitHub stars
- 76 contributors
- backed by ruby-pg maintainers

## Related

- Works with [PostgreSQL](https://talira.ai/catalog/postgresql-cm55wcnd.md)

## Alternatives

- [sqlite3-ruby](https://talira.ai/catalog/sqlite3-ruby-7nwbmdjq.md): Ruby bindings for the SQLite3 embedded database
- [mysql2](https://talira.ai/catalog/mysql2-r38appf6.md): Fast MySQL and MariaDB client library for Ruby, binding to libmysqlclient

## Sources

[^1]: https://github.com/ged/ruby-pg/blob/master/LICENSE (checked 27 Nov 2026)
[^2]: https://github.com/ged/ruby-pg/blob/master/pg.gemspec (checked 27 Nov 2026)
