mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-07-04 03:33:03 +03:00
Added documentation for Unicode support in large object
Not implemented yet!
This commit is contained in:
parent
79048ff19a
commit
2cde9033ac
|
@ -490,13 +490,14 @@ The ``connection`` class
|
||||||
|
|
||||||
.. method:: lobject([oid [, mode [, new_oid [, new_file [, lobject_factory]]]]])
|
.. method:: lobject([oid [, mode [, new_oid [, new_file [, lobject_factory]]]]])
|
||||||
|
|
||||||
Return a new database large object. See :ref:`large-objects` for an
|
Return a new database large object as a `~psycopg2.extensions.lobject`
|
||||||
overview.
|
instance.
|
||||||
|
|
||||||
|
See :ref:`large-objects` for an overview.
|
||||||
|
|
||||||
:param oid: The OID of the object to read or write. 0 to create
|
:param oid: The OID of the object to read or write. 0 to create
|
||||||
a new large object and and have its OID assigned automatically.
|
a new large object and and have its OID assigned automatically.
|
||||||
:param mode: Access mode to the object: can be ``r``, ``w``,
|
:param mode: Access mode to the object, see below.
|
||||||
``rw`` or ``n`` (meaning don't open it).
|
|
||||||
:param new_oid: Create a new object using the specified OID. The
|
:param new_oid: Create a new object using the specified OID. The
|
||||||
function raises `OperationalError` if the OID is already in
|
function raises `OperationalError` if the OID is already in
|
||||||
use. Default is 0, meaning assign a new one automatically.
|
use. Default is 0, meaning assign a new one automatically.
|
||||||
|
@ -504,13 +505,31 @@ The ``connection`` class
|
||||||
(using the |lo_import|_ function)
|
(using the |lo_import|_ function)
|
||||||
:param lobject_factory: Subclass of
|
:param lobject_factory: Subclass of
|
||||||
`~psycopg2.extensions.lobject` to be instantiated.
|
`~psycopg2.extensions.lobject` to be instantiated.
|
||||||
:rtype: `~psycopg2.extensions.lobject`
|
|
||||||
|
|
||||||
.. |lo_import| replace:: `!lo_import()`
|
.. |lo_import| replace:: `!lo_import()`
|
||||||
.. _lo_import: http://www.postgresql.org/docs/9.0/static/lo-interfaces.html#LO-IMPORT
|
.. _lo_import: http://www.postgresql.org/docs/9.0/static/lo-interfaces.html#LO-IMPORT
|
||||||
|
|
||||||
|
Available values for *mode* are:
|
||||||
|
|
||||||
|
======= =========
|
||||||
|
*mode* meaning
|
||||||
|
======= =========
|
||||||
|
``r`` Open for read only
|
||||||
|
``w`` Open for write only
|
||||||
|
``rw`` Open for read/write
|
||||||
|
``n`` Don't open the file
|
||||||
|
``b`` Don't decode read data (return data as `str` in Python 2 or `bytes` in Python 3)
|
||||||
|
``t`` Decode read data according to `connection.encoding` (return data as `unicode` in Python 2 or `str` in Python 3)
|
||||||
|
======= =========
|
||||||
|
|
||||||
|
``b`` and ``t`` can be specified together with a read/write mode. If
|
||||||
|
neither ``b`` nor ``t`` is specified, the default is ``b`` in Python 2
|
||||||
|
and ``t`` in Python 3.
|
||||||
|
|
||||||
.. versionadded:: 2.0.8
|
.. versionadded:: 2.0.8
|
||||||
|
|
||||||
|
.. versionchanged:: 2.3.3 added ``b`` and ``t`` mode and unicode
|
||||||
|
support.
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: Methods related to asynchronous support.
|
.. rubric:: Methods related to asynchronous support.
|
||||||
|
|
|
@ -51,17 +51,29 @@ functionalities defined by the |DBAPI|_.
|
||||||
|
|
||||||
.. attribute:: mode
|
.. attribute:: mode
|
||||||
|
|
||||||
The mode the database was open (``r``, ``w``, ``rw`` or ``n``).
|
The mode the database was open. See `connection.lobject()` for a
|
||||||
|
description of the available modes.
|
||||||
|
|
||||||
.. method:: read(bytes=-1)
|
.. method:: read(bytes=-1)
|
||||||
|
|
||||||
Read a chunk of data from the current file position. If -1 (default)
|
Read a chunk of data from the current file position. If -1 (default)
|
||||||
read all the remaining data.
|
read all the remaining data.
|
||||||
|
|
||||||
|
The result is an Unicode string (decoded according to
|
||||||
|
`connection.encoding`) if the file was open in ``t`` mode, a bytes
|
||||||
|
string for ``b`` mode.
|
||||||
|
|
||||||
|
.. versionchanged:: 2.3.3
|
||||||
|
added Unicode support.
|
||||||
|
|
||||||
.. method:: write(str)
|
.. method:: write(str)
|
||||||
|
|
||||||
Write a string to the large object. Return the number of bytes
|
Write a string to the large object. Return the number of bytes
|
||||||
written.
|
written. Unicode strings are encoded in the `connection.encoding`
|
||||||
|
before writing.
|
||||||
|
|
||||||
|
.. versionchanged:: 2.3.3
|
||||||
|
added Unicode support.
|
||||||
|
|
||||||
.. method:: export(file_name)
|
.. method:: export(file_name)
|
||||||
|
|
||||||
|
|
|
@ -574,7 +574,8 @@ whole.
|
||||||
|
|
||||||
Psycopg allows access to the large object using the
|
Psycopg allows access to the large object using the
|
||||||
`~psycopg2.extensions.lobject` class. Objects are generated using the
|
`~psycopg2.extensions.lobject` class. Objects are generated using the
|
||||||
`connection.lobject()` factory method.
|
`connection.lobject()` factory method. Data can be retrieved either as bytes
|
||||||
|
or as Unicode strings.
|
||||||
|
|
||||||
Psycopg large object support efficient import/export with file system files
|
Psycopg large object support efficient import/export with file system files
|
||||||
using the |lo_import|_ and |lo_export|_ libpq functions.
|
using the |lo_import|_ and |lo_export|_ libpq functions.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user