Ruby + Postgres on fedora
For persons who want to use postgres database on a Ruby program, a package are available.
To install this package use this command :
-
yum install ruby-postgres
You can use this sample of code to test installation :
-
#!/usr/bin/ruby
-
require ‘postgres’
-
-
conn = PGconn.connect("host", 5432, ”, ”, "database", "user", "password")
-
-
res = conn.exec(‘select tablename, tableowner from pg_tables’)
-
-
res.each do |row|
-
row.each do |column|
-
print column
-
(20-column.length).times{print " "}
-
end
-
puts
-
end
-
Ruby Extention :
http://rubyforge.org/projects/ruby-postgres/