Reducing Code (again)

J

Jigar Gosar

Following is some code that I came up with, for small db processing. I
have a feeling that I could be further reduced to be more concise.
Something feels off, I can't put my finger on it. Or maybe for such a
small task its pretty decent.

Le me know.
thanks.


module MSDB
DELETE_RESPONSE_TIME_LOG_QUERY = "delete from responsetimelog"

def copy_results suffix
transaction do |con|
con.do "select * into responsetimelog_#{suffix} from
responsetimelog"
con.do DELETE_RESPONSE_TIME_LOG_QUERY
end
end

def clear_response_time_log
transaction do |con|
con.do DELETE_RESPONSE_TIME_LOG_QUERY
end
end

private
def transaction
DBI.connect("...") do |con|
yield con
con.commit
end
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top