Commit 70f80800 authored by aoh's avatar aoh
Browse files

Update example


Signed-off-by: aoh's avataraoh <aoh@lysator.liu.se>
parent be5d36ad
......@@ -18,3 +18,17 @@ class DB():
with self.connection.cursor() as cursor:
cursor.execute('SELECT id FROM domain')
return [item.get("id") for item in cursor.fetchall()]
def get_subdomain_ids(self, domainid):
with self.connection.cursor() as cursor:
cursor.execute('SELECT id FROM subdomain WHERE domainid = %s', domainid)
return [item.get("id") for item in cursor.fetchall()]
def get_key(self, subid):
with self.connection.cursor() as cursor:
cursor.execute('SELECT secret FROM update_key WHERE subid = %s LIMIT 1', subid)
secret = cursor.fetchone()
if secret is None:
return None
else:
return secret.get("secret")
......@@ -31,5 +31,10 @@ finally:
connection.close()
print("dump db")
with DB() as d:
print(d.get_user_ids())
for id in d.get_user_ids():
print("domain id: ", id)
for sid in d.get_subdomain_ids(id):
print("subdomain id: ", sid)
print("subdomain secret: ", d.get_key(sid))
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