From 6b8861d2d5f938aa08d85dc691a71fff843caf75 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 15 Oct 2012 00:38:28 +0100 Subject: [PATCH] Clarification in copy_expert docs Closes ticket #134. --- doc/src/cursor.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/src/cursor.rst b/doc/src/cursor.rst index 3a17ebe1..c7badb8b 100644 --- a/doc/src/cursor.rst +++ b/doc/src/cursor.rst @@ -559,10 +559,19 @@ The ``cursor`` class |COPY|__ command documentation). :param sql: the :sql:`COPY` statement to execute. - :param file: a file-like object; must be a readable file for - :sql:`COPY FROM` or an writable file for :sql:`COPY TO`. + :param file: a file-like object to read or write (according to *sql*). :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: >>> cur.copy_expert("COPY test TO STDOUT WITH CSV HEADER", sys.stdout)