Home

pg

Submitting Issues

Please take a look at these guidelines before submitting an issue to this tracker.

Documentation

The library comes with full RDoc API documentation, and there are a number of samples of more-esoteric features in the sample/ directory.

Description

Pg is the Ruby interface to the PostgreSQL RDBMS.

It works with PostgreSQL 8.3 and later.

A small example usage:

#!/usr/bin/env ruby
  
require 'pg'
  
# Output a table of current connections to the DB
conn = PG.connect( 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

Requirements

  • Ruby 1.8.7-p249 or 1.9.3-p0.
  • PostgreSQL 8.3.x (with headers, -dev packages, etc).

It may work with earlier versions of Ruby 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>

See README-OS_X.rdoc for more information about installing under MacOS X, and README-Windows.rdoc for Windows build/installation instructions.

There's also a Google+ group and a mailing list if you get stuck, or just want to chat about something.

Contributing

You can report bugs, suggest features, or check out the source with Mercurial from this site, or if you prefer, there's also a Github mirror.

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 maintainer is Michael Granger <ged@FaerieMUD.org>.

Copying

Copyright © 1997-2012 by the authors.

  • Jeff Davis <ruby-pg@j-davis.com>
  • Guy Decoux (ts) <decoux@moulon.inra.fr>
  • Michael Granger <ged@FaerieMUD.org>
  • Dave Lee
  • Eiji Matsumoto <usagi@ruby.club.or.jp>
  • Yukihiro Matsumoto <matz@ruby-lang.org>
  • Noboru Saitou <noborus@netlab.jp>

You may redistribute this software under the same terms as Ruby itself; see http://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.

Acknowledgments

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.

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.