Changeset 447 for trunk/docs


Ignore:
Timestamp:
Oct 16, 2012, 3:16:05 PM (7 years ago)
Author:
cito
Message:

Added a namedresult() method to the classic API.

Location:
trunk/docs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/changelog.txt

    r446 r447  
    1010  This an effective way to pass arbitrary or unknown data without worrying
    1111  about SQL injection or syntax errors (contribution by Patrick TJ McPhee).
     12- The classic API now supports a method namedresult() in addition to
     13  getresult() and dictresult(), which returns the rows of the result
     14  as named tuples if these are supported (Python 2.6 or higher).
    1215- The execute() and executemany() methods now return the cursor object,
    1316  so you can now write statements like "for row in cursor.execute(...)"
  • trunk/docs/pg.txt

    r446 r447  
    7575
    7676Exceptions raised:
    77   :Type: bad argument type, or too many arguments
     77  :TypeError: bad argument type, or too many arguments
    7878  :SyntaxError: duplicate argument definition
    7979  :pg.InternalError: some error occurred during pg connection definition
     
    385385  used by PyGreSQL to hold PostgreSQL numeric values. The default class
    386386  is decimal.Decimal if available, otherwise the float type is used.
     387 
     388set_namedresult -- set a function that will convert to named tuples
     389-------------------------------------------------------------------
     390Syntax::
     391
     392  set_namedresult(func)
     393
     394Parameters:
     395  :func: the function to be used to convert results to named tuples
     396
     397Description:
     398  You can use this if you want to create different kinds of named tuples.
     399 
    387400
    388401Module constants
     
    448461  string. If it is a statement that returns rows as a result (usually a select
    449462  statement, but maybe also an "insert/update ... returning" statement), this
    450   method returns a `pgqueryobject` that can be accessed via the `getresult()`
    451   or `dictresult()` method or simply printed. Otherwise, it returns `None`.
     463  method returns a `pgqueryobject` that can be accessed via the `getresult()`,
     464  `dictresult()` or `namedresult()` methods or simply printed. Otherwise, it
     465  returns `None`.
    452466
    453467  The query may optionally contain positional parameters of the form `$1`,
     
    11591173
    11601174Exceptions raised:
    1161   :TypeError: too many parameters
     1175  :TypeError: too many (any) parameters
    11621176  :MemoryError: internal memory error
    11631177
     
    11801194
    11811195Exceptions raised:
    1182   :TypeError: too many parameters
     1196  :TypeError: too many (any) parameters
    11831197  :MemoryError: internal memory error
    11841198
     
    11881202  used as the dictionary index.
    11891203
     1204namedresult - get query values as list of named tuples
     1205------------------------------------------------------
     1206Syntax::
     1207
     1208  namedresult()
     1209
     1210Parameters:
     1211  None
     1212
     1213Return type:
     1214  :list: result values as a list of named tuples
     1215
     1216Exceptions raised:
     1217  :TypeError: too many (any) parameters
     1218  :TypeError: named tuples not supported
     1219  :MemoryError: internal memory error
     1220
     1221Description:
     1222  This method returns the list of the values returned by the query
     1223  with each row returned as a named tuple with proper field names.
    11901224
    11911225listfields - lists fields names of previous query result
Note: See TracChangeset for help on using the changeset viewer.