Commit 22686e68 authored by aoh's avatar aoh
Browse files

db.py: Add get_subdomain_ids_without_keys


Signed-off-by: aoh's avataraoh <aoh@lysator.liu.se>
parent 878259a1
......@@ -50,3 +50,11 @@ class DB():
'INNER JOIN record_types ON subdomain.rr = record_types.id '
'WHERE subdomain.id = %s LIMIT 1', subid)
return cursor.fetchone()
def get_subdomain_ids_without_keys(self, domainid):
with self.connection.cursor() as cursor:
cursor.execute('SELECT subdomain.id '
'FROM subdomain '
'LEFT OUTER JOIN update_key ON subdomain.id = update_key.subid '
'WHERE subdomain.id = %s AND update_key.secret IS NULL', domainid)
return [item.get("id") for item in cursor.fetchall()]
#!/usr/bin/env python3
from db import DB
print("dump db")
with DB() as d:
print("dump db")
for id in d.get_domain_ids():
print("domain id: ", id)
print("domain name: ", d.get_domain_name(id))
......@@ -11,3 +11,8 @@ with DB() as d:
print("domain name: ", d.get_subdomain_name(sid))
print("subdomain secret: ", d.get_key(sid))
print("record: ", d.get_record(sid))
print("\nDomains without keys")
for id in d.get_domain_ids():
domain_name = d.get_domain_name(id)
for sid in d.get_subdomain_ids_without_keys(id):
print("domain name: ", d.get_subdomain_name(sid) + "." + domain_name)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment