Afternoon, On Mon, Oct 22, 2012 at 12:28 PM, François Beausoleil < [email protected]> wrote:
> Hi! > > I have a large result set which I'm streaming to CSV files. I know I could > use #sql to get the SQL, and run that through psql and output plain old CSV > files. I'm trying to avoid that, one of the reason being at the point where > I know the query, I have no access to the username / password. > I'm not sure you want to go down this road - but you can invoke the PostgreSQL copy command from the raw driver and have it return the CSV data to you directly that you could push out to a file. The relevant pieces of code are scattered inside the "psql" sample for the ruby-pg driver (search for handlecopyout). Basically, you send out the copy command to stdout via the driver and then keep calling .getline on the connection until it finishes. It's actually pretty straight forward once you get the pieces together - I don't have a sample on hand so I'm sorry that the description is a little fuzzy at best :) John -- 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.
