Pg is the Ruby interface to the PostgreSQL RDBMS.
It works with PostgreSQL 8.4 and later.
A small example usage:
#!/usr/bin/env ruby require 'pg' # Output a table of current connections to the DB conn = .( dbname: 'sales' ) conn.exec( "SELECT * FROM pg_stat_activity" ) do |result| puts " PID | User | Query" result.each do |row| puts " %7d | %-16s | %s " % row.values_at('procpid', 'usename', 'current_query') end end
Ruby 1.9.3-p392, or 2.0.0-p0.
PostgreSQL 8.4.x or later (with headers, -dev packages, etc).
It may work with earlier versions of Ruby/PostgreSQL as well, but those are not regularly tested.
How To Install
Install via RubyGems:
gem install pg
You may need to specify the path to the 'pg_config' program installed with Postgres:
gem install pg -- --with-pg-config=<path to pg_config>
If you're installing via Bundler, you can provide compile hints like so:
bundle config build.pg --with-pg-config=<path to pg_config>
See README-OS_X.rdoc for more information about installing under MacOS X, and README-Windows.rdoc for Windows build/installation instructions.
After checking out the source, run:
$ rake newb
This task will install any missing dependencies, run the tests/specs, and generate the API documentation.
The current maintainers are Michael Granger <ged@FaerieMUD.org> and Lars Kanis <email@example.com>.
Copyright © 1997-2013 by the authors.
Jeff Davis <firstname.lastname@example.org>
Guy Decoux (ts) <email@example.com>
Michael Granger <ged@FaerieMUD.org>
Lars Kanis <firstname.lastname@example.org>
Eiji Matsumoto <email@example.com>
Yukihiro Matsumoto <firstname.lastname@example.org>
Noboru Saitou <email@example.com>
You may redistribute this software under the same terms as Ruby itself; see www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source for details.
Portions of the code are from the PostgreSQL project, and are distributed under the terms of the PostgreSQL license, included in the file POSTGRES.
Portions copyright LAIKA, Inc.
See Contributors.rdoc for the many additional fine people that have contributed to this library over the years.
We are thankful to the people at the ruby-list and ruby-dev mailing lists. And to the people who developed PostgreSQL.