This commit is contained in:
Yapollon 2024-02-02 09:28:36 +01:00
parent c710fe7a78
commit 6464c0538e

View File

@ -45,9 +45,9 @@ def get_user_by_email(email: str):
def update_user(id: int, name: str, email: str, password: str = None): def update_user(id: int, name: str, email: str, password: str = None):
now = datetime.now().isoformat() now = datetime.now().isoformat()
if password: if password:
query = f"UPDATE users SET name = '{name}', email = '{email}', password = '{password}', updated_at = {now} WHERE id = {id};" query = f"UPDATE users SET name = '{name}', email = '{email}', password = '{password}', updated_at = '{now}' WHERE id = {id};"
else: else:
query = f"UPDATE users SET name = '{name}', email = '{email}', updated_at = {now} WHERE id = {id};" query = f"UPDATE users SET name = '{name}', email = '{email}', updated_at = '{now}' WHERE id = {id};"
conn = con3() conn = con3()
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute(query) cursor.execute(query)
@ -144,7 +144,7 @@ def get_slots(user_id: int):
def update_slot(id: int, slot: int): def update_slot(id: int, slot: int):
now = datetime.now().isoformat() now = datetime.now().isoformat()
query = f"UPDATE habits SET slot = {slot}, updated_at = {now} WHERE id = {id};" query = f"UPDATE habits SET slot = {slot}, updated_at = '{now}' WHERE id = {id};"
conn = con3() conn = con3()
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute(query) cursor.execute(query)
@ -155,7 +155,7 @@ def update_slot(id: int, slot: int):
def update_habit(id: int, name: str, note: str, times: int, unit: int): def update_habit(id: int, name: str, note: str, times: int, unit: int):
now = datetime.now().isoformat() now = datetime.now().isoformat()
query = f"UPDATE habits SET name = {name}, note = {note}, times = {times}, unit = {unit}, updated_at = {now} WHERE id = {id};" query = f"UPDATE habits SET name = {name}, note = {note}, times = {times}, unit = {unit}, updated_at = '{now}' WHERE id = {id};"
conn = con3() conn = con3()
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute(query) cursor.execute(query)