From: Brian Candler Date: 2011-08-01T02:39:45+09:00 Subject: Re: How to connect to and use Postgresql from Ruby Rannug Pong wrote in post #1014012: > I have just started to learn Ruby, quite nice language, but I'm stuck on > connecting to the database (Postgresql) > > I have installed some ruby-pg and Ruby/DBI package for my Ubuntu system, > but then what? You did google for "ruby DBI"? There's a good introductory article on kitebird. However, DBI is a pretty old layer and not well maintained. I think that most people would either: (1) use a higher-level abstraction layer such as ActiveRecord, Datamapper or Sequel. All three of those have good documentation, and will happily sit on top of a postgres database; or (2) use the ruby-pg layer directly (look at its documentation for examples). Option (2) arguably gives the best performance, but that's irrelevant because the time for the database to perform a SQL query will far outweigh the time to send the request. Option (1) gives you much easier ways to interact with the database, and also makes it easier for your code to be database-independent. On an Ubuntu system, my personal inclination is to ignore the Ubuntu-provided packages and instead install everything as gems. That gives you much more control and the ability to install more recent packages (or specific versions of packages). HTH, Brian. -- Posted via http://www.ruby-forum.com/.