Newer
Older
from sys import argv
import psycopg2
def get_connection():
db_connect = psycopg2.connect(host="localhost", database="postgres", user="postgres", password="postgres")
db_connect.set_session(autocommit=True)
return db_connect
def is_admin(username: str) -> bool:
conn = get_connection()
with conn.cursor() as cursor:
cursor.execute("""SELECT is_admin FROM users WHERE username = '%s' """ % username)
# fetchone gibt NONE zurück, falls kein Benutzer gefunden wird