Changeset 817 for trunk/docs


Ignore:
Timestamp:
Feb 4, 2016, 3:18:08 PM (3 years ago)
Author:
cito
Message:

Support the hstore data type

Added adaptation and typecasting of the hstore type as Python dictionaries.
For the typecasting, a fast parser has been added to the C extension.

Location:
trunk/docs/contents
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/contents/changelog.rst

    r814 r817  
    77- The supported versions are Python 2.6 to 2.7, and 3.3 to 3.5.
    88- PostgreSQL is supported in all versions from 9.0 to 9.5.
    9 - Changes in the DB-API 2 module (pgdb):
    10     - The DB-API 2 module now always returns result rows as named tuples
    11       instead of simply lists as before. The documentation explains how
    12       you can restore the old behavior or use custom row objects instead.
    13     - The names of the various classes used by the classic and DB-API 2
    14       modules have been renamed to become simpler, more intuitive and in
    15       line with the names used in the DB-API 2 documentation.
    16       Since the API provides only objects of these types through constructor
    17       functions, this should not cause any incompatibilities.
    18     - The DB-API 2 module now supports the callproc() cursor method. Note
    19       that output parameters are currently not replaced in the return value.
    20     - The DB-API 2 module now supports copy operations between data streams
    21       on the client and database tables via the COPY command of PostgreSQL.
    22       The cursor method copy_from() can be used to copy data from the database
    23       to the client, and the cursor method copy_to() can be used to copy data
    24       from the client to the database.
    25     - The 7-tuples returned by the description attribute of a pgdb cursor
    26       are now named tuples, i.e. their elements can be also accessed by name.
    27       The column names and types can now also be requested through the
    28       colnames and coltypes attributes, which are not part of DB-API 2 though.
    29       The type_code provided by the description attribute is still equal to
    30       the PostgreSQL internal type name, but now carries some more information
    31       in additional attributes. The size, precision and scale information that
    32       is part of the description is now properly set for numeric types.
    33     - If you pass a Python list as one of the parameters to a DB-API 2 cursor,
    34       it is now automatically bound using an ARRAY constructor. If you pass a
    35       Python tuple, it is bound using a ROW constructor. This is useful for
    36       passing records as well as making use of the IN syntax.
    37     - Inversely, when a fetch method of a DB-API 2 cursor returns a PostgreSQL
    38       array, it is passed to Python as a list, and when it returns a PostgreSQL
    39       composite type, it is passed to Python as a named tuple. PyGreSQL uses
    40       a new fast built-in parser to achieve this. Anonymous composite types are
    41       also supported, but yield only an ordinary tuple containing text strings.
    42     - A new type helper Interval() has been added.
    439- Changes in the classic PyGreSQL module (pg):
    4410    - The classic interface got two new methods get_as_list() and get_as_dict()
     
    9258      can be set to specify whether parameters should be sent to the database
    9359      separately or formatted into the SQL.
    94     - The methods for adapting and typecasting values pertaining to PostgreSQL
    95       types have been refactored and swapped out to separate classes.
    9660    - A new type helper Bytea() has been added.
     61- Changes in the DB-API 2 module (pgdb):
     62    - The DB-API 2 module now always returns result rows as named tuples
     63      instead of simply lists as before. The documentation explains how
     64      you can restore the old behavior or use custom row objects instead.
     65    - The names of the various classes used by the classic and DB-API 2
     66      modules have been renamed to become simpler, more intuitive and in
     67      line with the names used in the DB-API 2 documentation.
     68      Since the API provides only objects of these types through constructor
     69      functions, this should not cause any incompatibilities.
     70    - The DB-API 2 module now supports the callproc() cursor method. Note
     71      that output parameters are currently not replaced in the return value.
     72    - The DB-API 2 module now supports copy operations between data streams
     73      on the client and database tables via the COPY command of PostgreSQL.
     74      The cursor method copy_from() can be used to copy data from the database
     75      to the client, and the cursor method copy_to() can be used to copy data
     76      from the client to the database.
     77    - The 7-tuples returned by the description attribute of a pgdb cursor
     78      are now named tuples, i.e. their elements can be also accessed by name.
     79      The column names and types can now also be requested through the
     80      colnames and coltypes attributes, which are not part of DB-API 2 though.
     81      The type_code provided by the description attribute is still equal to
     82      the PostgreSQL internal type name, but now carries some more information
     83      in additional attributes. The size, precision and scale information that
     84      is part of the description is now properly set for numeric types.
     85    - If you pass a Python list as one of the parameters to a DB-API 2 cursor,
     86      it is now automatically bound using an ARRAY constructor. If you pass a
     87      Python tuple, it is bound using a ROW constructor. This is useful for
     88      passing records as well as making use of the IN syntax.
     89    - Inversely, when a fetch method of a DB-API 2 cursor returns a PostgreSQL
     90      array, it is passed to Python as a list, and when it returns a PostgreSQL
     91      composite type, it is passed to Python as a named tuple. PyGreSQL uses
     92      a new fast built-in parser to achieve this. Anonymous composite types are
     93      also supported, but yield only an ordinary tuple containing text strings.
     94    - A new type helper Interval() has been added.
    9795- Changes concerning both modules:
    9896    - The modules now provide get_typecast() and set_typecast() methods
     
    107105      strings.  You can restore the old behavior by deactivating the respective
    108106      typecast functions, e.g. set_typecast('date', None).
    109     - PyGreSQL now supports the JSON and JSONB data types, converting such
     107    - PyGreSQL now supports the "hstore" data type, converting such columns
     108      automatically to and from Python dictionaries.  If you want to insert
     109      Python objects as JSON data using DB-API 2, you should wrap them in the
     110      new HStore() type constructor as a hint to PyGreSQL.
     111    - PyGreSQL now supports the "json" and "jsonb" data types, converting such
    110112      columns automatically to and from Python objects. If you want to insert
    111113      Python objects as JSON data using DB-API 2, you should wrap them in the
    112114      new Json() type constructor as a hint to PyGreSQL.
    113     - The new type helpers Literal() and Json() have been added.
    114     - Fast parsers cast_array() and cast_record() for the input and output
    115       syntax for PostgreSQL arrays and composite types have been added to the
    116       C extension module. The array parser also allows using multi-dimensional
    117       arrays with PyGreSQL.
     115    - A new type helper Literal() for inserting parameters literally as SQL
     116      has been added.  This is useful for table names, for instance.
     117    - Fast parsers cast_array(), cast_record() and cast_hstore for the input
     118      and output syntax for PostgreSQL arrays, composite types and the hstore
     119      type have been added to the C extension module. The array parser also
     120      allows using multi-dimensional arrays with PyGreSQL.
    118121    - The tty parameter and attribute of database connections has been
    119122      removed since it is not supported any more since PostgreSQL 7.4.
  • trunk/docs/contents/pg/module.rst

    r814 r817  
    716716
    717717The module provides the following type helper functions.  You can wrap
    718 parameters with these functions when passing them to :meth:`DB.query_formatted`
    719 in order to give PyGreSQL a hint about the type of the parameters.
     718parameters with these functions when passing them to :meth:`DB.query`
     719or :meth:`DB.query_formatted` in order to give PyGreSQL a hint about the
     720type of the parameters, if it cannot be derived from the context.
    720721
    721722.. function:: Bytea(bytes)
     
    725726.. versionadded:: 5.0
    726727
     728.. function:: HStore(dict)
     729
     730    A wrapper for holding an hstore dictionary
     731
     732.. versionadded:: 5.0
     733
    727734.. function:: Json(obj)
    728735
     
    731738.. versionadded:: 5.0
    732739
     740The following additional type helper is only meaningful when used with
     741:meth:`DB.query_formatted`.  It marks a parameter as text that shall be
     742literally included into the SQL.  This is useful for passing table names
     743for instance.
     744
    733745.. function:: Literal(sql)
    734746
     
    736748
    737749.. versionadded:: 5.0
     750
    738751
    739752Module constants
  • trunk/docs/contents/pgdb/module.rst

    r814 r817  
    100100call :meth:`TypeCache.reset_typecast` on the :attr:`Connection.type_cache`.
    101101
    102 
    103102Module constants
    104103----------------
  • trunk/docs/contents/pgdb/types.rst

    r814 r817  
    6464
    6565    Construct an object capable of holding a bytea value
     66
     67.. versionadded:: 5.0
     68
     69.. function:: Interval(days, hours=0, minutes=0, seconds=0, microseconds=0)
     70
     71    Construct an object holding a time interval value
     72
     73.. versionadded:: 5.0
     74
     75.. function:: Hstore(dict)
     76
     77    Construct a wrapper for holding an hstore dictionary
    6678
    6779.. versionadded:: 5.0
Note: See TracChangeset for help on using the changeset viewer.