Files
TJWaterServer/api/_1_title.py
2022-09-01 22:20:38 +08:00

20 lines
635 B
Python

from _connection import _conn_dict as conn
def have_title(name: str) -> bool:
with conn[name].cursor() as cur:
cur.execute(f"SELECT * FROM TITLE")
return cur.rowcount > 0
def set_title(name: str, value: str) -> None:
if have_title(name):
with conn[name].cursor() as cur:
cur.execute(f"UPDATE TITLE SET Value = {value}")
else:
with conn[name].cursor() as cur:
cur.execute(f"INSERT INTO TITLE (Value) VALUES ('{value}')")
def unset_title(name: str) -> None:
with conn[name].cursor() as cur:
cur.execute(f"TRUNCATE TITLE")
return cur.rowcount > 0