Joe Van Dyk wrote:
I've got a query that returns a *lot* of data and I need it CSV
formatted and returned to the user (in a browser).

Postgresql can output stuff in CSV format, and it seems like it would
be efficient to let postgresql format the result and return that
result exactly as is to the user.  Instead of having sequel load the
data into a hash, then have ruby do csv processing.

Is there a good way to do that with sequel?  (Or maybe directly with
the pg gem?)

With the 'pg' library you can read from a COPY like so:

  conn.exec( "COPY logs TO STDOUT WITH csv" )
  $stdout.puts( buf ) while buf = conn.get_copy_data

I'll be adding an example of this under the samples/ directory of the gem shortly.

--
Michael Granger <[email protected]>
http://deveiate.org/


--
You received this message because you are subscribed to the Google Groups 
"sequel-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/sequel-talk?hl=en.

Reply via email to