Re: support for COPY

Jan UrbaƄski <[email protected]> Sat, 03 Jul 2010 22:59:20 +0200
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On 03/07/10 22:31, Manlio Perillo wrote:
> By the way, requiring a file object seems to make things more complex as
> they should be if COPY data come from a producer; that is data is
> produced on the fly.
> 
> In this case, what is the best solution using psycopg2 API?

The producer would just have to implement the read(size) method that
would block until enough data is produced to satisfy the caller and
return a string.

You could write an adapter class that would use a Queue and run the
producer and the COPY operations in separate threads, or things like that.

I'm also planning to add asynchronous COPY support that would make it
possible to use the Twisted producer/consumer interface, if you're doing
Twisted.

Cheers,
Jan