SQL Search in Ruby

Ok, this seems like a duplicate question to this: SQL Super Search but it's a different approach. Before I was looking for a lean and efficient way to do this entirely on the database side, but now I was wondering if anyone knoew how to do something like this in Ruby.

I've tried this, and while I can run a basic


I can't seem to run subsequent queries without getting

' WARNING: #<ODBC::Statement:0x2c73e84> was not dropped before garbage collection. '

Can someone show me a really easy way to just run sql text and parse the results (and ideally run more queries based on those results)?

EDIT: To clarify, my db code so far is along the lines of:

oConn = DBI.connect('DBI:ODBC:AX')
oConn2 = DBI.connect('DBI:ODBC:AX')

sth = oConn.execute("Select table\_name, column\_name from information\_schema.columns")
sth.fetch do |row|
  table = row["table\_name"]
  column = row["column\_name"]
  puts table + "," + column
 #Dynamic sql here
  sth2.fetch do |row2|
    puts row2[0]
13.10.2009 16:06:32

That warning is a feature, according to Christian Werner. Try oConn.finish after oConn.execute and don't forget to .disconnect in the end.

irb(main):033:0> require 'dbi'
=> false

irb(main):034:0> oConn=DBI.connect('DBI:ODBC:Blacklisted')
=> #<DBI::DatabaseHandle:0x2d50af0 @trace_mode=2, @handle=#<DBI::DBD::ODBC::Database:0x2d50a3c @attr={}, @handle=#<ODBC::Database:0x2d50a64>>, @trace_output=#<IO:0x2846adc>>

irb(main):035:0> sth = oConn.execute("Select * from blacklistednews where id=12140")
=> #<DBI::StatementHandle:0x2d4c838 @trace_mode=2, @fetchable=true, @row=[nil, nil, nil, nil, nil, nil], @handle=#<DBI::DBD::ODBC::Statement:0x2d4c784 @arr=[],@params=[], handle=#<ODBC::Statement:0x2d4c7c0>>, @cols=["id", "title", "url","description", "pubdate", "synced"], @trace_output=#<IO:0x2846adc>, @prepared=false>

irb(main):036:0> sth.finish
=> nil

irb(main):037:0> oConn.disconnect
=> nil

18.11.2009 21:22:22
I get a NoMethodError on 'drop'
LoveMeSomeCode 18.11.2009 16:48:45
i still get it with finish: odbc.rb:7: undefined method `finish' for #<DBI::DatabaseHandle:0x2d4e4f8> (NoMethodError)
LoveMeSomeCode 18.11.2009 19:23:41