57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
from db_logging import log_change
|
|
|
|
|
|
def set_name(cursor, name):
|
|
cursor.execute("DELETE FROM metadata")
|
|
cursor.execute(
|
|
"INSERT INTO metadata (name) VALUES (%s)",
|
|
(name,)
|
|
)
|
|
log_change(cursor, f"Updated metadata name to {name}")
|
|
|
|
|
|
def get_name(cursor):
|
|
cursor.execute("SELECT name FROM metadata LIMIT 1")
|
|
row = cursor.fetchone()
|
|
return row["name"] if row else None
|
|
|
|
|
|
def set_comment(cursor, comment):
|
|
cursor.execute("DELETE FROM metadata")
|
|
cursor.execute(
|
|
"INSERT INTO metadata (comment) VALUES (%s)",
|
|
(comment,)
|
|
)
|
|
log_change(cursor, f"Updated metadata comment to {comment}")
|
|
|
|
|
|
def get_comment(cursor):
|
|
cursor.execute("SELECT comment FROM metadata LIMIT 1")
|
|
row = cursor.fetchone()
|
|
return row["comment"] if row else None
|
|
|
|
|
|
def set_keys(cursor, public_key, private_key):
|
|
cursor.execute("DELETE FROM metadata")
|
|
cursor.execute(
|
|
"""
|
|
INSERT INTO metadata (public_key, private_key)
|
|
VALUES (%s, %s)
|
|
""",
|
|
(public_key, private_key)
|
|
)
|
|
log_change(cursor, "Updated metadata keys")
|
|
|
|
|
|
def get_public_key(cursor):
|
|
cursor.execute("SELECT public_key FROM metadata LIMIT 1")
|
|
row = cursor.fetchone()
|
|
return row["public_key"] if row else None
|
|
|
|
|
|
def get_private_key(cursor):
|
|
cursor.execute("SELECT private_key FROM metadata LIMIT 1")
|
|
row = cursor.fetchone()
|
|
return row["private_key"] if row else None
|
|
|