I have a requirement to have a dns query function to query a server for various records. I figured out how to get the MX record (most of the examples show this), A record and NS
You can try something a bit different.
Instead of querying each time per record type, you can make a single query for ANY record. This way if that domain has both TXT, CNAME etc... you'll get one object with all the data.
from dns.resolver import dns
name_server = '8.8.8.8' #Google's DNS server
ADDITIONAL_RDCLASS = 65535
request = dns.message.make_query('google.com', dns.rdatatype.ANY)
request.flags |= dns.flags.AD
request.find_rrset(request.additional, dns.name.root, ADDITIONAL_RDCLASS,
dns.rdatatype.OPT, create=True, force_unique=True)
response = dns.query.udp(request, name_server)
Hope this might assist you.