MAJOR: Reworked database to be easier to use and close automatically to prevent resource leaks

This commit is contained in:
JustIceO7
2025-01-29 17:47:29 +00:00
parent 83b458ed99
commit dfdbe4a7d4
9 changed files with 181 additions and 209 deletions

View File

@@ -51,7 +51,6 @@ def get_past_chat(stream_id: int):
# Connect to the database
db = Database()
db.create_connection()
# fetched in format: [(chatter_id, message, time_sent)]
all_chats = db.fetchall("""
@@ -103,7 +102,6 @@ def send_chat(data) -> None:
def save_chat(chatter_id, stream_id, message):
"""Save the chat to the database"""
db = Database()
db.create_connection()
db.execute("""
INSERT INTO chat (chatter_id, stream_id, message)
VALUES (?, ?, ?);""", (chatter_id, stream_id, message))