GNU Info

Info Node: (python2.1-lib.info)Database Objects

(python2.1-lib.info)Database Objects


Prev: dbhash Up: dbhash
Enter node , (file) or (file)node

Database Objects
----------------

The database objects returned by `open()' provide the methods common to
all the DBM-style databases.  The following methods are available in
addition to the standard methods.

`first()'
     It's possible to loop over every key in the database using this
     method and the `next()' method.  The traversal is ordered by the
     databases internal hash values, and won't be sorted by the key
     values.  This method returns the starting key.

`last()'
     Return the last key in a database traversal.  This may be used to
     begin a reverse-order traversal; see `previous()'.

`next(key)'
     Returns the key that follows KEY in the traversal.  The following
     code prints every key in the database `db', without having to
     create a list in memory that contains them all:

          k = db.first()
          while k != None:
              print k
              k = db.next(k)

`previous(key)'
     Return the key that comes before KEY in a forward-traversal of the
     database.  In conjunction with `last()', this may be used to
     implement a reverse-order traversal.

`sync()'
     This method forces any unwritten data to be written to the disk.


automatically generated by info2www version 1.2.2.9