mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 18:33:44 +03:00
dictcursor-docs-improvement
This commit is contained in:
parent
779a1370ce
commit
96f0f63de2
|
@ -41,8 +41,8 @@ If you want to use a `!connection` subclass you can pass it as the
|
||||||
Dictionary-like cursor
|
Dictionary-like cursor
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
The dict cursors allow to access to the retrieved records using an interface
|
The dict cursors allow to access to the attributes of retrieved records
|
||||||
similar to the Python dictionaries instead of the tuples.
|
using an interface similar to the Python dictionaries instead of the tuples.
|
||||||
|
|
||||||
>>> dict_cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
>>> dict_cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||||
>>> dict_cur.execute("INSERT INTO test (num, data) VALUES(%s, %s)",
|
>>> dict_cur.execute("INSERT INTO test (num, data) VALUES(%s, %s)",
|
||||||
|
|
|
@ -130,7 +130,10 @@ class DictConnection(_connection):
|
||||||
|
|
||||||
|
|
||||||
class DictCursor(DictCursorBase):
|
class DictCursor(DictCursorBase):
|
||||||
"""A cursor that keeps a list of column name -> index mappings."""
|
"""A cursor that keeps a list of column name -> index mappings__.
|
||||||
|
|
||||||
|
.. __: https://docs.python.org/glossary.html#term-mapping
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs['row_factory'] = DictRow
|
kwargs['row_factory'] = DictRow
|
||||||
|
|
Loading…
Reference in New Issue
Block a user