PostgreSQL 7.1.3 Documentation
Prev | Chapter 9. PyGreSQL - Python Interface | Next

# 9.4. Database wrapper class: `DB`

`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.):

    import pg

    db = pg.DB(...)

    for r in db.query(
        "SELECT foo,bar
           FROM foo_bar_table
          WHERE foo !~ bar"
        ).dictresult():

        print '%(foo)s %(bar)s' % r

The following describes the methods and variables of this class.

The `DB` class is initialized with the same arguments as the `pg.connect` method. It also initializes a few internal variables. The statement `db = DB()` will open the local database with the name of the user just like `pg.connect()` does.

Prev | Home | Next
loimport | Up | pkey