3.3. Making queries

This tutorial is a follow-up to Creating and configuring a session and potentially one of Loading repositories (to have some packages to query for), you can prepend them directly for a functional piece of code.

1# Create a package query.
2query = libdnf5.rpm.PackageQuery(base)
3
4# Filter the packages, the filters can be stacked one after another.
5query.filter_name(["one"])
6
7# Iterate over the filtered packages in the query.
8for pkg in query:
9    print(pkg.get_nevra())