mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
Added documentation for the bytea parser
This commit is contained in:
parent
e0cd6f0f00
commit
da58bee70a
2
NEWS
2
NEWS
|
@ -1,6 +1,8 @@
|
||||||
What's new in psycopg 2.4.1
|
What's new in psycopg 2.4.1
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
- Use own parser for bytea output, not requiring anymore the libpq 9.0
|
||||||
|
to parse the hex format.
|
||||||
- Correctly detect an empty query sent to the backend (ticket #46).
|
- Correctly detect an empty query sent to the backend (ticket #46).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,9 @@ Psycopg converts :sql:`decimal`\/\ :sql:`numeric` database types into Python `!D
|
||||||
Transferring binary data from PostgreSQL 9.0 doesn't work.
|
Transferring binary data from PostgreSQL 9.0 doesn't work.
|
||||||
PostgreSQL 9.0 uses by default `the "hex" format`__ to transfer
|
PostgreSQL 9.0 uses by default `the "hex" format`__ to transfer
|
||||||
:sql:`bytea` data: the format can't be parsed by the libpq 8.4 and
|
:sql:`bytea` data: the format can't be parsed by the libpq 8.4 and
|
||||||
earlier. Three options to solve the problem are:
|
earlier. The problem is solved in Psycopg 2.4.1, that uses its own parser
|
||||||
|
for the :sql:`bytea` format. For previous Psycopg releases, three options
|
||||||
|
to solve the problem are:
|
||||||
|
|
||||||
- set the bytea_output__ parameter to ``escape`` in the server;
|
- set the bytea_output__ parameter to ``escape`` in the server;
|
||||||
- execute the database command ``SET bytea_output TO escape;`` in the
|
- execute the database command ``SET bytea_output TO escape;`` in the
|
||||||
|
|
|
@ -271,6 +271,10 @@ the SQL string that would be sent to the database.
|
||||||
.. versionchanged:: 2.4
|
.. versionchanged:: 2.4
|
||||||
only strings were supported before.
|
only strings were supported before.
|
||||||
|
|
||||||
|
.. versionchanged:: 2.4.1
|
||||||
|
can parse the 'hex' format from 9.0 servers without relying on the
|
||||||
|
version of the client library.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
In Python 2, if you have binary data in a `!str` object, you can pass them
|
In Python 2, if you have binary data in a `!str` object, you can pass them
|
||||||
|
@ -282,18 +286,15 @@ the SQL string that would be sent to the database.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
PostgreSQL 9 uses by default `a new "hex" format`__ to emit :sql:`bytea`
|
Since version 9.0 PostgreSQL uses by default `a new "hex" format`__ to
|
||||||
fields. Unfortunately this format can't be parsed by libpq versions
|
emit :sql:`bytea` fields. Starting from Psycopg 2.4.1 the format is
|
||||||
before 9.0. This means that using a library client with version lesser
|
correctly supported. If you use a previous version you will need some
|
||||||
than 9.0 to talk with a server 9.0 or later you may have problems
|
extra care when receiving bytea from PostgreSQL: you must have at least
|
||||||
receiving :sql:`bytea` data. To work around this problem you can set the
|
the libpq 9.0 installed on the client or alternatively you can set the
|
||||||
`bytea_output`__ parameter to ``escape``, either in the server
|
`bytea_output`__ configutation parameter to ``escape``, either in the
|
||||||
configuration or in the client session using a query such as ``SET
|
server configuration file or in the client session (using a query such as
|
||||||
bytea_output TO escape;`` before trying to receive binary data.
|
``SET bytea_output TO escape;``) before receiving binary data.
|
||||||
|
|
||||||
Starting from Psycopg 2.4 this condition is detected and signaled with a
|
|
||||||
`~psycopg2.InterfaceError`.
|
|
||||||
|
|
||||||
.. __: http://www.postgresql.org/docs/9.0/static/datatype-binary.html
|
.. __: http://www.postgresql.org/docs/9.0/static/datatype-binary.html
|
||||||
.. __: http://www.postgresql.org/docs/9.0/static/runtime-config-client.html#GUC-BYTEA-OUTPUT
|
.. __: http://www.postgresql.org/docs/9.0/static/runtime-config-client.html#GUC-BYTEA-OUTPUT
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user