Skip to content

Instantly share code, notes, and snippets.

@mikiobraun
Created March 3, 2010 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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