Changeset 745 for trunk/docs


Ignore:
Timestamp:
Jan 14, 2016, 8:16:23 PM (4 years ago)
Author:
cito
Message:

Add methods get/set_parameter to DB wrapper class

These methods can be used to get/set/reset run-time parameters,
even several at once.

Since this is pretty useful and will not break anything, I have
also back ported these additions to the 4.x branch.

Everything is well documented and tested, of course.

Location:
trunk/docs/contents
Files:
2 edited

Legend:

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

    r730 r745  
    4343Version 4.2
    4444-----------
    45 - Set a better default for the user option "escaping-funcs".
    4645- The supported Python versions are 2.4 to 2.7.
    4746- PostgreSQL is supported in all versions from 8.3 to 9.5.
     47- Set a better default for the user option "escaping-funcs".
    4848- Force build to compile with no errors.
     49- New methods get_parameters() and set_parameters() in the classic interface
     50  which can be used to get or set run-time parameters.
    4951- Fix decimal point handling.
    5052- Add option to return boolean values as bool objects.
  • trunk/docs/contents/pg/db_wrapper.rst

    r739 r745  
    121121
    122122    :param str table: name of table
    123     :returns: A dictionary -- the keys are the attribute names,
    124      the values are the type names of the attributes.
     123    :returns: a dictionary mapping attribute names to type names
    125124
    126125Given the name of a table, digs out the set of attribute names.
     
    135134You can get the regular types after enabling this by calling the
    136135:meth:`DB.use_regtypes` method.
    137 
    138136
    139137has_table_privilege -- check table privilege
     
    152150
    153151.. versionadded:: 4.0
     152
     153get/set_parameter -- get or set  run-time parameters
     154----------------------------------------------------
     155
     156.. method:: DB.get_parameter(parameter)
     157
     158    Get the value of run-time parameters
     159
     160    :param parameter: the run-time parameter(s) to get
     161    :type param: str, tuple, list or dict
     162    :returns: the current value(s) of the run-time parameter(s)
     163    :rtype: str, list or dict
     164    :raises TypeError: Invalid parameter type(s)
     165    :raises ProgrammingError: Invalid parameter name(s)
     166
     167If the parameter is a string, the return value will also be a string
     168that is the current setting of the run-time parameter with that name.
     169
     170You can get several parameters at once by passing a list or tuple of
     171parameter names.  The return value will then be a corresponding list
     172of parameter settings.  If you pass a dict as parameter instead, its
     173values will be set to the parameter settings corresponding to its keys.
     174
     175By passing the special name `'all'` as the parameter, you can get a dict
     176of all existing configuration parameters.
     177
     178.. versionadded:: 4.2
     179
     180.. method:: DB.set_parameter(self, parameter, [value], [local])
     181
     182    Set the value of run-time parameters
     183
     184    :param parameter: the run-time parameter(s) to set
     185    :type param: string, tuple, list or dict
     186    :param value: the value to set
     187    :type param: str or None
     188    :raises TypeError: Invalid parameter type(s)
     189    :raises ValueError: Invalid value argument(s)
     190    :raises ProgrammingError: Invalid parameter name(s) or values
     191
     192If the parameter and the value are strings, the run-time parameter
     193will be set to that value.  If no value or *None* is passed as a value,
     194then the run-time parameter will be restored to its default value.
     195
     196You can set several parameters at once by passing a list or tuple
     197of parameter names, with a single value that all parameters should
     198be set to or with a corresponding list or tuple of values.
     199
     200You can also pass a dict as parameters.  In this case, you should
     201not pass a value, since the values will be taken from the dict.
     202
     203By passing the special name `'all'` as the parameter, you can reset
     204all existing settable run-time parameters to their default values.
     205
     206If you set *local* to `True`, then the command takes effect for only the
     207current transaction.  After :meth:`DB.commit` or :meth:`DB.rollback`,
     208the session-level setting takes effect again.  Setting *local* to `True`
     209will appear to have no effect if it is executed outside a transaction,
     210since the transaction will end immediately.
     211
     212.. versionadded:: 4.2
    154213
    155214begin/commit/rollback/savepoint/release -- transaction handling
Note: See TracChangeset for help on using the changeset viewer.