Compare commits
2 Commits
b925683aa4
...
52ba6988fd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52ba6988fd | ||
|
|
cc8f2f56a1 |
2
app.py
2
app.py
@ -142,4 +142,4 @@ def logout():
|
||||
|
||||
# Run the application
|
||||
if __name__ == '__main__':
|
||||
app.run(port=5000, debug=True)
|
||||
app.run(port=5000, debug=True)
|
||||
@ -41,6 +41,17 @@ def get_user_by_email(email: str):
|
||||
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):
|
||||
now = datetime.now().isoformat()
|
||||
query = (f"INSERT INTO habits (user_id, name, note, times, unit, list_index, created_at, updated_at) VALUES ('{user_id}', "
|
||||
@ -58,9 +69,9 @@ def get_habit(id: int):
|
||||
conn = con3()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(query)
|
||||
habits = cursor.fetchone()
|
||||
habit = cursor.fetchone()
|
||||
conn.close()
|
||||
return habits
|
||||
return habit
|
||||
|
||||
|
||||
def get_habits(user_id: int):
|
||||
@ -68,6 +79,15 @@ def get_habits(user_id: int):
|
||||
conn = con3()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(query)
|
||||
habits = cursor.fetchone()
|
||||
habits = cursor.fetchall()
|
||||
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