The Ruby interface to PostgreSQL
open sourceBSD-2-Clause OR Rubyfree
pg is the Ruby interface to PostgreSQL, 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.
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
Alternatives
The same job
These do what pg does.
- sqlite3-ruby Ruby bindings for the SQLite3 embedded database
- mysql2 Fast MySQL and MariaDB client library for Ruby, binding to libmysqlclient
