Commit be5d36ad authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Merge branch 'master' of git.lysator.liu.se:jiffe/LysMemberDNS

parents 43a4dee5 62724dba
import pymysql
class DB():
def __init__(self):
pass
def __enter__(self):
self.connection = pymysql.connect(host='lysns.lysator.liu.se',
user='lysns',
password='hunter2',
db='lysns',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
return self
def __exit__(self, type, value, traceback):
self.connection.close()
def get_user_ids(self):
with self.connection.cursor() as cursor:
cursor.execute('SELECT id FROM domain')
return [item.get("id") for item in cursor.fetchall()]
#!/usr/bin/env python3
import pymysql.cursors
from db import DB
connection = pymysql.connect(host='lysns.lysator.liu.se',
user='lysns',
......@@ -28,3 +29,7 @@ try:
finally:
connection.close()
with DB() as d:
print(d.get_user_ids())
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