[Rpm-maint] [rpm-software-management/rpm] Add real-life examples of Python RPM (PR #3177)

Panu Matilainen notifications at github.com
Mon Jun 24 09:51:02 UTC 2024


@pmatilai commented on this pull request.



> @@ -0,0 +1,11 @@
+#!/usr/bin/python3
+
+# Query all installed packages.
+# A Python equivalent for `rpm -qa`
+
+import rpm
+
+ts = rpm.TransactionSet()
+mi = ts.dbMatch()
+for hdr in mi:

Similar issues exist with the 'ts' handle of course - doesn't matter at all in such small examples but people commonly don't realize that the 'ts' handle will also keep the database open for much longer than intended.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177#discussion_r1650718999
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/3177/review/2135265302 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20240624/6e01e629/attachment.html>


More information about the Rpm-maint mailing list