On Thu, 2008-10-02 at 11:41 +0100, Carl Drinkwater | 29degrees wrote:
> Or simpler, IMHO at least, use the MySQL adapter directly. Again,
> untested though :
>
> csv = FasterCSV.open( target_file, "w" )
> res = ActiveRecord::Base.connection.execute( your_sql )
>
> # Header
> csv << res.fetch_fields.map { |f| f.name }
>
> # Results
> res.each do |row_data|
> csv << row_data
> end
>
> csv.close
>
Nice - that's a very tidy solution. I'm assuming the each method on res
fetches the rows one at a time from the MySQL server, rather than
grabbing them all at once.
John.
--
http://www.brightbox.co.uk - UK Ruby on Rails hosting
http://johnleach.co.uk
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"NWRUG" 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/nwrug-members?hl=en
-~----------~----~----~----~------~----~------~--~---