diff --git a/doc/src/sgml/pygresql.sgml b/doc/src/sgml/pygresql.sgml index 8a002036bbf..3b854d46735 100644 --- a/doc/src/sgml/pygresql.sgml +++ b/doc/src/sgml/pygresql.sgml @@ -1,4 +1,4 @@ - + <application>PyGreSQL</application> - <application>Python</application> Interface @@ -2413,12 +2413,17 @@ loimport(filename) Database Wrapper Class: <classname>DB</classname> - pg module contains a class called - DB. All pgobject - methods are included in this class also. A number of additional - DB class methods are described below. The - preferred way to use this module is as follows (See description of - the initialization method below.): + The pg module contains a class called + DB wrapping a pgobject. + This pgobject can be addressed as a + DB class member named db + to get access to the read-only attributes of the corresponding connection + (e.g. db.error). All pgobject + methods (e.g. query()) are directly included as members + in the class DB also. A number of additional + higher level DB class methods are described below. + The preferred way to use this module is as follows (see description of the + initialization method below): import pg diff --git a/src/interfaces/python/pg.py b/src/interfaces/python/pg.py index df502397fa6..0e40a6e5a47 100644 --- a/src/interfaces/python/pg.py +++ b/src/interfaces/python/pg.py @@ -48,14 +48,10 @@ class DB: def __init__(self, *args, **kw): self.db = apply(connect, args, kw) - # Create convience methods, in a way that is still overridable. - for e in ( 'query', 'reset', 'close', 'getnotify', 'inserttable', - 'putline', 'getline', 'endcopy', - 'host', 'port', 'db', 'options', - 'tty', 'error', 'status', 'user', - 'locreate', 'getlo', 'loimport' ): - if not hasattr(self,e) and hasattr(self.db,e): - exec 'self.%s = self.db.%s' % ( e, e ) + # Create convience methods, in a way that is still overridable + # (members are not copied because they are actually functions) + for e in self.db.__methods__: + setattr(self, e, getattr(self.db, e)) self.__attnames__ = {} self.__pkeys__ = {}