From: Sean Chittenden Date: 2002-05-24T14:55:48+09:00 Subject: Re: cannot require 'postgres' from cgi > > Why aren't you using DBI? > > just one more thing to learn - haven't had time. plus i'd read some > things about speed issues and hadn't had time to investigate. what > are you opinions of it? Use DBI 0.0.14 or later and the speed problems should be nil. I use DBI for tons of operations and as of yesterday, pumped over 30M rows through it w/o a hitch. :~) Need a quick example? dbh = DBI.connect('dbi:postgres:dbname:hostname','user','pass') sql = 'SELECT or, some, other, sql, here FROM my_table AS mt WHERE mt.val1 = ? mt.val2 = ?' dbh.select_all(sql, val1, val2) do |row| # do stuff w/ your row (array coresponding to the columns) end dbh.disconnect Don't forget you can also use transactions: dbh.transaction do |t| # t is just a normal DBH object t.do('INSERT INTO foo (val1, val2) VALUES (?,?)', val1, val2) end and statement handles: sql = 'INSERT INTO foo (val1, val2) VALUES (?,?)' dbh.prepare(sql) do |sth| # t is just a normal DBH object sth.execute(val1, val2) end statement handles are nice and faster for repeat operations. You can also go sth = dbh.prepare(sql): it's just a style preference. > turns out (this took me a LONG time to determine) that the > postgres.so lib has dependancies on other libs which are not to be > found in the LD_LIBRARY_PATH (empty) of the default cgi environment > but that WERE found in my own LD_LIBRARY_PATH. > > it's a little troublesome that 'require' is unable to throw for this > sort of error... > > anyhow, i'm unsure of where to go from here > > - install postgress libs in /usr/lib > - modify ENV of running cgi > - staticaly link the postgres lib > > ??? > > any opinions on this? See if you can set LD_RUN_PATH and recompile your postgres libs, then you won't have to worry about LD_LIBRARY_PATH in the future. Something tells me you're on Solaris, yes? If so, I'm sorry. :~) That OS has all kinds of strange SO problems from my experience. Not impossible to overcome, just a PITA. -- Sean Chittenden