Skip to content

Instantly share code, notes, and snippets.

@mikiobraun
Created March 3, 2010 14:22
Show Gist options
  • Save mikiobraun/320637 to your computer and use it in GitHub Desktop.
Save mikiobraun/320637 to your computer and use it in GitHub Desktop.
# gems you need
#
# dbi
# dbd-jdbc
# jdbc-postgres
require 'java'
require 'rubygems'
require 'dbi'
require 'dbd/Jdbc'
require 'jdbc/postgres'
# connect to database 'foobar'
# with user 'foobar' and password 'quux'
DBI.connect('DBI:Jdbc:postgresql://localhost/foobar',
'foobar', 'quux',
'driver' => 'org.postgresql.Driver') do |dbh|
puts "Connected"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment