Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

rpmdb Class Reference

A python rpmdb object represents an RPM database. More...


Detailed Description

A python rpmdb object represents an RPM database.

Instances of the rpmdb object provide access to the records of a RPM database. The records are accessed by index number. To retrieve the header data in the RPM database, the rpmdb object is subscripted as you would access members of a list.

The rpmdb class contains the following methods:

To obtain a rpmdb object, the opendb function in the rpm module must be called. The opendb function takes two optional arguments. The first optional argument is a boolean flag that specifies if the database is to be opened for read/write access or read-only access. The second argument specifies an alternate root directory for RPM to use.

An example of opening a database and retrieving the first header in the database, then printing the name of the package that the header represents:

        import rpm
        rpmdb = rpm.opendb()
        index = rpmdb.firstkey()
        header = rpmdb[index]
        print header[rpm.RPMTAG_NAME]
To print all of the packages in the database that match a package name, the code will look like this:
        import rpm
        rpmdb = rpm.opendb()
        indexes = rpmdb.findbyname("foo")
        for index in indexes:
            header = rpmdb[index]
            print "%s-%s-%s" % (header[rpm.RPMTAG_NAME],
                                header[rpm.RPMTAG_VERSION],
                                header[rpm.RPMTAG_RELEASE])


The documentation for this class was generated from the following file:
Generated at Thu Sep 6 11:25:49 2001 for rpm by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001