I'm building a class that will iterate across a range of databases and 
perform the same query on each one. The queries return an array of numbers 
that will get passed on for statistical analysis. I want to pass in the 
names of the databases, the table, and the query to perform in the class 
constructor.

The meat of the class would look like

database_names.each.with_index do |database_name, idx|
  db = Sequel.connect(database_name)
  result[idx] = db[<:table>].<query>
  db.close
end

Passing in the database names and symbol for the table is easy enough. 
Passing in the query is tricky.

I've been working with .send() and making good progress. For example:

table = :my_table
query = [:select, :NodeId]

db[table].send(*query)

=> #<Sequel::SQLite::Dataset: "SELECT `NodeId` FROM `my_table`

But I not getting anywhere with where clauses.

query = [[:select, :NodeId], [:where, :Timestamp, :"=>", :"60"]]

db[table].send(*query[0]).send(*query[1]) # Obviously automate the 
unrolling of a variable-length query

=> #<Sequel::SQLite::Dataset: "SELECT `NodeId` FROM `my_table` WHERE 
(`Timestamp` AND `=>` AND `60`)">

How can I get that where clause to evaluate to "WHERE ('Timestamp' = 60)"?

I'm not an experienced Ruby coder and am clearly missing some nuances of 
the language when it comes to send() and treatment of symbols...

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to