Home | Trees | Indices | Help |
|
---|
|
GNUmed PostgreSQL connection handling. TODO: iterator/generator batch fetching: - http://groups-beta.google.com/group/comp.lang.python/msg/7ff516d7d9387dad - search Google for "Geneator/Iterator Nesting Problem - Any Ideas? 2.4" winner: def resultset_functional_batchgenerator(cursor, size=100): for results in iter(lambda: cursor.fetchmany(size), []): for rec in results: yield rec
Author: K.Hilbert <Karsten.Hilbert@gmx.net>
License: GPL v2 or later (details at http://www.gnu.org)
Classes | |
cConnectionPool GNUmed database connection pool. |
|
cAuthenticationError | |
cEncodingError | |
cAdapterPyDateTime |
Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Variables | |
postgresql_version_string = None
|
|
postgresql_version = None
|
|
auto_request_login_params = True
|
|
known_schema_hashes =
|
|
map_schema_hash2version =
|
|
map_client_branch2required_db_version =
|
|
query_table_col_defs =
|
|
query_table_attributes =
|
|
SQL_foreign_key_name =
|
|
__package__ =
|
Imports: time, sys, os, codecs, types, logging, pydt, regex, gmLoginInfo, gmExceptions, gmDateTime, gmBorg, gmI18N, gmLog2, prompted_input, u_replacement_character, dbapi, psycopg2, sql_error_codes, FixedOffsetTimezone
Function Details |
Get the foreign keys pointing to schema.table.column. Does not properly work with multi-column FKs. GNUmed doesn't use any, however. |
Set the user language in the database. user = None: current db user language = None: unset |
Set the user language in the database. - regardless of whether there is any translation available. - only for the current user |
Uses pg_advisory(_shared). - locks stack and need one unlock per lock - same connection: - all locks succeed - different connections: - shared + shared succeed - shared + exclusive fail |
Uses pg_advisory_unlock(_shared). - each lock needs one unlock |
Looks at pk_locks - does not take into account locks other than 'advisory', however |
Store data from a bytea field into a file. <data_query> - dict {'cmd': ..., 'args': ...} - 'cmd' must be unicode containing "... substring(data from %(start)s for %(size)s) ..." - 'args' must be a dict - must return one row with one field of type bytea <file> - must be a file like Python object <data_size> - integer of the total size of the expected data or None <data_size_query> - dict {'cmd': ..., 'args': ...} - cmd must be unicode - must return one row with one field with the octet_length() of the data field - used only when <data_size> is None |
Store data from a file into a bytea field. The query must: - be in unicode - contain a format spec identifying the row (eg a primary key) matching <args> if it is an UPDATE - contain a format spec %(data)s::bytea |
Escape input for use in a PostgreSQL regular expression. If a fragment comes from user input and is to be used as a regular expression we need to make sure it doesn't contain invalid regex patterns such as unbalanced ('s. <escape_all> True: try to escape *all* metacharacters False: only escape those which render the regex invalid |
Run read-only queries. <queries> must be a list of dicts: [ {'cmd': <string>, 'args': <dict> or <tuple>}, {...}, ... ] |
Convenience function for running a transaction that is supposed to get committed. <link_obj> can be either: - a cursor - a connection <queries> is a list of dicts [{'cmd': <string>, 'args': <dict> or <tuple>) to be executed as a single transaction, the last query may usefully return rows (such as a "SELECT currval('some_sequence')" statement) <end_tx> - controls whether the transaction is finalized (eg. committed/rolled back) or not, this allows the call to run_rw_queries() to be part of a framing transaction - if link_obj is a connection then <end_tx> will default to False unless it is explicitly set to True which is taken to mean "yes, you do have full control over the transaction" in which case the transaction is properly finalized - if link_obj is a cursor we CANNOT finalize the transaction because we would need the connection for that - if link_obj is None <end_tx> will, of course, always be True <return_data> - if true, the returned data will include the rows the last query selected - if false, it returns None instead <get_col_idx> - if true, the returned data will include a dictionary mapping field names to column positions - if false, the returned data returns None instead method result: - returns a tuple (data, idx) - <data>: * (None, None) if last query did not return rows * ("fetchall() result", <index>) if last query returned any rows * for <index> see <get_col_idx> |
Generates SQL for an INSERT query. values: dict of values keyed by field to insert them into |
Get a raw, unadorned connection. - this will not set any parameters such as encoding, timezone, datestyle - the only requirement is a valid DSN - hence it can be used for "service" connections for verifying encodings etc |
Get a new connection. This assumes the locale system has been initialized unless an encoding is specified. |
Check server time and local time to be within the given tolerance of each other. tolerance: seconds |
Checks database settings. returns (status, message) status: 0: no problem 1: non-fatal problem 2: fatal problem |
Variables Details |
known_schema_hashes
|
map_schema_hash2version
|
map_client_branch2required_db_version
|
query_table_col_defs
|
query_table_attributes
|
SQL_foreign_key_name
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Aug 3 03:55:54 2013 | http://epydoc.sourceforge.net |