Hi Can you try like
The following can be moved to lib
module ActiveRecord
class Base
def self.to_csv(sql_statement)
self.connection.instance_variable_get(:@connection).exec("copy
(#{sql_statement}) TO STDOUT WITH CSV")
csv = []
while (line = pg_conn.getline) != "\\."
csv << line
end
return csv.join("\n")
end
end
end
And can access like ActiveRecord::Base.to_csv(sql_here)
Sijo
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---