Text Size: Normal / Large

6.4. Database Wrapper Class: DB

Table of Contents
pkey -- return the primary key of a table
get_databases -- get list of databases in the system
get_tables -- get list of tables in connected database
get_attnames -- return the attribute names of a table
get -- get a tuple from a database table
insert -- insert a tuple into a database table
update -- update a database table
clear -- clear a database table
delete -- delete a row from a table

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.


User Comments

No comments could be found for this page.

Add Comment

Please use this form to add your own comments regarding your experience with particular features of PostgreSQL, clarifications of the documentation, or hints for other users. Please note, this is not a support forum, and your IP address will be logged. If you have a question or need help, please see the faq, try a mailing list, or join us on IRC. Note that submissions containing URLs or other keywords commonly found in 'spam' comments may be silently discarded. Please contact the webmaster if you think this is happening to you in error.

In order to submit a comment, you must have a community account.

* Comment
 

* denotes required field

Privacy Policy | Project hosted by hub.org | Designed by tinysofa
Copyright © 1996 – 2007 PostgreSQL Global Development Group