Wordsmithing on COPY commands

Address somehow issue #397.
This commit is contained in:
Daniele Varrazzo 2016-07-01 01:39:10 +01:00
parent 5f3be39e0a
commit 05f23df238
2 changed files with 13 additions and 2 deletions

View File

@ -494,6 +494,9 @@ The ``cursor`` class
.. rubric:: COPY-related methods .. rubric:: COPY-related methods
Efficiently copy data from file-like objects to the database and back. See
:ref:`copy` for an overview.
.. extension:: .. extension::
The :sql:`COPY` command is a PostgreSQL extension to the SQL standard. The :sql:`COPY` command is a PostgreSQL extension to the SQL standard.
@ -502,7 +505,7 @@ The ``cursor`` class
.. method:: copy_from(file, table, sep='\\t', null='\\\\N', size=8192, columns=None) .. method:: copy_from(file, table, sep='\\t', null='\\\\N', size=8192, columns=None)
Read data *from* the file-like object *file* appending them to Read data *from* the file-like object *file* appending them to
the table named *table*. See :ref:`copy` for an overview. the table named *table*.
:param file: file-like object to read data from. It must have both :param file: file-like object to read data from. It must have both
`!read()` and `!readline()` methods. `!read()` and `!readline()` methods.

View File

@ -864,11 +864,19 @@ Using COPY TO and COPY FROM
Psycopg `cursor` objects provide an interface to the efficient Psycopg `cursor` objects provide an interface to the efficient
PostgreSQL |COPY|__ command to move data from files to tables and back. PostgreSQL |COPY|__ command to move data from files to tables and back.
Currently no adaptation is provided between Python and PostgreSQL types on
|COPY|: the file can be any Python file-like object but its format must be in
the format accepted by `PostgreSQL COPY command`__ (data fromat, escaped
characters, etc).
.. __: COPY_
The methods exposed are: The methods exposed are:
`~cursor.copy_from()` `~cursor.copy_from()`
Reads data *from* a file-like object appending them to a database table Reads data *from* a file-like object appending them to a database table
(:sql:`COPY table FROM file` syntax). The source file must have both (:sql:`COPY table FROM file` syntax). The source file must provide both
`!read()` and `!readline()` method. `!read()` and `!readline()` method.
`~cursor.copy_to()` `~cursor.copy_to()`