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:
| index | current rpmdb location |
| file | absolute path to file |
| name | package name |
| dep | provided dependency string |
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] 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])
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001