Created dbutils.py for easy database manipulation

main
Anorak_1 2023-08-08 17:26:45 +02:00
parent a7d187a645
commit 11ed17f2ea
1 changed files with 23 additions and 0 deletions

23
dbutil.py 100644
View File

@ -0,0 +1,23 @@
import json
import os
import sqlite3
def add_application_msg(msg_id: str, author_id: str, guild_id: str) -> None:
data = (msg_id, author_id, guild_id)
con = sqlite3.connect("applications.db")
cur = con.cursor()
cur.execute("INSERT INTO app_msg_db VALUES (?, ?, ?)", data)
con.commit()
def get_application_msg(msg_id: str):
con = sqlite3.connect("applications.db")
cur = con.cursor()
cur.execute(f"SELECT user_id, guild_id FROM app_msg_db WHERE msg_id={msg_id}")
user_id, guild_id = cur.fetchone()
return user_id, guild_id
def remove_application_msg(msg_id: str) -> None:
con = sqlite3.connect("applications.db")
cur = con.cursor()
cur.execute(f"DELETE FROM app_msg_db WHERE msg_id={msg_id}")
con.commit()