mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-23 01:16:34 +03:00
parent
71393b9ae9
commit
6b8861d2d5
|
@ -559,10 +559,19 @@ The ``cursor`` class
|
||||||
|COPY|__ command documentation).
|
|COPY|__ command documentation).
|
||||||
|
|
||||||
:param sql: the :sql:`COPY` statement to execute.
|
:param sql: the :sql:`COPY` statement to execute.
|
||||||
:param file: a file-like object; must be a readable file for
|
:param file: a file-like object to read or write (according to *sql*).
|
||||||
:sql:`COPY FROM` or an writable file for :sql:`COPY TO`.
|
|
||||||
:param size: size of the read buffer to be used in :sql:`COPY FROM`.
|
:param size: size of the read buffer to be used in :sql:`COPY FROM`.
|
||||||
|
|
||||||
|
The *sql* statement should be in the form :samp:`COPY {table} TO
|
||||||
|
STDOUT` to export :samp:`{table}` to the *file* object passed as
|
||||||
|
argument or :samp:`COPY {table} FROM STDIN` to import the content of
|
||||||
|
the *file* object into :samp:`{table}`.
|
||||||
|
|
||||||
|
*file* must be a readable file-like object (as required by
|
||||||
|
`~cursor.copy_from()`) for *sql* statement :sql:`COPY ... FROM STDIN`
|
||||||
|
or a writable one (as required by `~cursor.copy_to()`) for :sql:`COPY
|
||||||
|
... TO STDOUT`.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
>>> cur.copy_expert("COPY test TO STDOUT WITH CSV HEADER", sys.stdout)
|
>>> cur.copy_expert("COPY test TO STDOUT WITH CSV HEADER", sys.stdout)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user