burgernotes-server/removeuser

33 lines
612 B
Plaintext
Raw Normal View History

2023-07-22 17:15:59 +01:00
#!/usr/bin/python3
import sqlite3
import sys
print("type n to cancel")
answer = input("delete user, what is user id?")
if answer == "n":
2023-07-22 17:15:59 +01:00
sys.exit()
2023-07-22 17:15:59 +01:00
def get_db_connection():
connection = sqlite3.connect("database.db")
connection.row_factory = sqlite3.Row
return connection
2023-07-22 17:15:59 +01:00
print("deleting notes")
conn = get_db_connection()
notes = conn.execute("DELETE FROM notes WHERE creator = ?", (int(answer),))
conn.commit()
conn.close()
print("deleting account")
conn = get_db_connection()
conn.execute("DELETE FROM users WHERE id = ?", (int(answer),))
conn.commit()
conn.close()
print("success")