Compare commits
No commits in common. "52ba6988fd33cda5700f7f3563364f25b6612b92" and "b925683aa42180c33f0b69171477616f77722207" have entirely different histories.
52ba6988fd
...
b925683aa4
2
app.py
2
app.py
@ -142,4 +142,4 @@ def logout():
|
|||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(port=5000, debug=True)
|
app.run(port=5000, debug=True)
|
||||||
|
|||||||
@ -41,17 +41,6 @@ def get_user_by_email(email: str):
|
|||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
||||||
def delete_user(id: int):
|
|
||||||
query = f"DELETE FROM habits WHERE user_id = {id};"
|
|
||||||
query2 = f"DELETE FROM users WHERE id = {id};"
|
|
||||||
conn = con3()
|
|
||||||
cursor = conn.cursor()
|
|
||||||
cursor.execute(query)
|
|
||||||
cursor.execute(query2)
|
|
||||||
conn.commit()
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def create_habit(name: str, user_id: int, times: int, unit: int, slot: int, note: str | None=None):
|
def create_habit(name: str, user_id: int, times: int, unit: int, slot: int, note: str | None=None):
|
||||||
now = datetime.now().isoformat()
|
now = datetime.now().isoformat()
|
||||||
query = (f"INSERT INTO habits (user_id, name, note, times, unit, list_index, created_at, updated_at) VALUES ('{user_id}', "
|
query = (f"INSERT INTO habits (user_id, name, note, times, unit, list_index, created_at, updated_at) VALUES ('{user_id}', "
|
||||||
@ -69,9 +58,9 @@ def get_habit(id: int):
|
|||||||
conn = con3()
|
conn = con3()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
habit = cursor.fetchone()
|
habits = cursor.fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
return habit
|
return habits
|
||||||
|
|
||||||
|
|
||||||
def get_habits(user_id: int):
|
def get_habits(user_id: int):
|
||||||
@ -79,15 +68,6 @@ def get_habits(user_id: int):
|
|||||||
conn = con3()
|
conn = con3()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
habits = cursor.fetchall()
|
habits = cursor.fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
return habits
|
return habits
|
||||||
|
|
||||||
|
|
||||||
def delete_habit(id: int):
|
|
||||||
query = f"DELETE FROM habits WHERE id = {id};"
|
|
||||||
conn = con3()
|
|
||||||
cursor = conn.cursor()
|
|
||||||
cursor.execute(query)
|
|
||||||
conn.commit()
|
|
||||||
conn.close()
|
|
||||||
Loading…
x
Reference in New Issue
Block a user