Having installed an RPM it is only natural want to know how to remove one. This is done by calling ts.addErase() by name.
import rpm ts=rpm.ts() ts.addErase("foo")
If you want to remove a particular package instance you can do this by getting the package instance by querying the database.
mi = ts.dbMatch(rpm.RPMTAG_NAME, "kernel") mi.pattern(rpm.RPMTAG_ARCH, rpm.RPMMIRE_DEFAULT, "i386") for idx in mi: instance = mi.instance() ts.addErase(instance)