mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Added some documentation for the hstore adaptation.
This commit is contained in:
parent
d5bf400cb4
commit
4b98e8941f
|
@ -86,6 +86,30 @@ Logging cursor
|
|||
|
||||
|
||||
|
||||
.. index::
|
||||
pair: hstore; Data types
|
||||
pair: dict; Adaptation
|
||||
|
||||
Hstore data type
|
||||
----------------
|
||||
|
||||
Python `dict` objects can be converted into the PostgreSQL |hstore|_ data
|
||||
type. Only dictionaries with string/unicode keys and values are supported.
|
||||
None are also allowed as values.
|
||||
|
||||
The |hstore| type has received a lot of improvements in the PostgreSQL 9.0
|
||||
release and the Psycopg adapter uses a more efficient representation if the
|
||||
new release is detected.
|
||||
|
||||
|
||||
.. |hstore| replace:: :sql:`hstore`
|
||||
.. _hstore: http://www.postgresql.org/docs/9.0/static/hstore.html
|
||||
|
||||
|
||||
.. autofunction:: register_hstore
|
||||
|
||||
|
||||
|
||||
.. index::
|
||||
pair: UUID; Data types
|
||||
|
||||
|
|
|
@ -186,6 +186,7 @@ argument of the `~cursor.execute()` method::
|
|||
|
||||
|
||||
.. index::
|
||||
single: Adaptation
|
||||
pair: Objects; Adaptation
|
||||
single: Data types; Adaptation
|
||||
|
||||
|
@ -294,6 +295,15 @@ the SQL string that would be sent to the database.
|
|||
was necessary to import the `~psycopg2.extensions` module to have it
|
||||
registered.
|
||||
|
||||
- Python dictionaries are converted into the |hstore|_ data type. See
|
||||
`~psycopg2.extras.register_hstore()` for further details.
|
||||
|
||||
.. |hstore| replace:: :sql:`hstore`
|
||||
.. _hstore: http://www.postgresql.org/docs/9.0/static/hstore.html
|
||||
|
||||
.. versionadded:: 2.2.3
|
||||
the :sql:`hstore` adaptation.
|
||||
|
||||
.. index::
|
||||
single: Unicode
|
||||
|
||||
|
|
|
@ -620,14 +620,14 @@ def register_hstore(conn_or_curs, globally=False, unicode=False):
|
|||
The function must receive a connection or cursor as the :sql:`hstore` oid
|
||||
is different in every database. The typecaster will be registered only on
|
||||
the connection or cursor passed as argument. If your application uses a
|
||||
single database you can pass *globally*=True to have hstore registered on
|
||||
all the connections.
|
||||
|
||||
Raise `~psycopg2.ProgrammingError` if hstore is not installed in the
|
||||
target database.
|
||||
single database you can pass *globally*\=True to have hstore registered
|
||||
on all the connections.
|
||||
|
||||
By default the returned dicts have string keys and values: use
|
||||
*unicode*=True to return `unicode` objects instead.
|
||||
*unicode*\=True to return `unicode` objects instead.
|
||||
|
||||
Raise `~psycopg2.ProgrammingError` if the :sql:`hstore` type is not
|
||||
installed in the target database.
|
||||
"""
|
||||
oids = HstoreAdapter.get_oids(conn_or_curs)
|
||||
if oids is None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user