I have a Ruby script that is connection to a postgres database, runs some queries, and then closes/returns data to the user.
The script works fine, but if I give it a bad hostname the entire script just hangs, and I have to ctrl-Z out of it. I know that to get around this I need to look into the libpq
backend for postgres, but I'm rather at a loss as to how to wrap it all up into my ruby script.
I'm using Ruby 1.8
and the pg gem
to handle the postgres stuff, call to open connection:
myConnection = PGconn.connect(host,port,pgOptions,pgTTY,name,user,password)
(options and tty are just blank strings)
Any help/tips/suggestions would be great!