Re: support for COPY
Jan UrbaĆski <[email protected]> Fri, 02 Jul 2010 14:21:26 +0200
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On 02/07/10 14:08, Joachim Worringen wrote:
> Greetings,
>
> I wonder whether psycopg2 support the COPY statement in the sense that
> either
> - a file which is accessible only by the client gets send to the server
> - the server accesses a file local to it
The former. More specifically, COPY support is psycopg2 means that it
can put the connection in COPY mode and start sending data using the
COPY libpq protocol feature. The psycopg2 implementation wants a
file-like object to provide data for the COPY operation, but that can be
either a disk file or a StringIO object or whatever else that looks like
a Python file.
If you want the server to read files using the SQL COPY command, you can
just do:
cur.execute("COPY tab FROM '/srv/file.dat')
Cheers,
Jan