CLEANUP: Tidied up backend code removed unused imports and debugging print statements

This commit is contained in:
JustIceO7
2025-03-06 17:26:41 +00:00
parent 9119df70b9
commit 5e9345463a
5 changed files with 19 additions and 38 deletions

View File

@@ -165,16 +165,14 @@ def newsletter_conf(email):
"""
# Check if user is already in database
db = Database()
db.create_connection()
user_exists = db.fetchone("""
SELECT *
FROM newsletter
WHERE email = ?;""",
(email,))
with Database() as db:
user_exists = db.fetchone("""
SELECT *
FROM newsletter
WHERE email = ?;""",
(email,))
print(user_exists, flush=True)
db.close_connection()
if user_exists is None:
add_to_newsletter(email)
@@ -186,30 +184,21 @@ def add_to_newsletter(email):
Add a person to the newsletter database
"""
# Create connection to the database
db = Database()
db.create_connection()
# Add the users email to the newsletter table
db.execute("""
INSERT INTO newsletter (email)
VALUES (?);
""", (email,))
with Database() as db:
# Add the users email to the newsletter table
db.execute("""
INSERT INTO newsletter (email)
VALUES (?);
""", (email,))
db.close_connection()
def remove_from_newsletter(email):
"""
Remove a person from the newsletter database
"""
# Create connection to the database
db = Database()
db.create_connection()
# Remove the users email from the newsletter table
db.execute("""
DELETE FROM newsletter
WHERE email = ?;
""", (email,))
db.close_connection()
with Database() as db:
# Remove the users email from the newsletter table
db.execute("""
DELETE FROM newsletter
WHERE email = ?;
""", (email,))