-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset_admin.py
More file actions
27 lines (21 loc) · 756 Bytes
/
Copy pathreset_admin.py
File metadata and controls
27 lines (21 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sqlite3
from werkzeug.security import generate_password_hash
import os
def reset_admin_password():
db_path = os.path.join(os.path.dirname(__file__), 'placement.db')
if not os.path.exists(db_path):
print("Database not found.")
return
new_password = input("Enter new admin password: ").strip()
if not new_password:
print("Password cannot be empty.")
return
conn = sqlite3.connect(db_path)
cur = conn.cursor()
hashed = generate_password_hash(new_password)
cur.execute("UPDATE admin SET password = ? WHERE username = 'admin'", (hashed,))
conn.commit()
conn.close()
print("Admin password successfully reset.")
if __name__ == "__main__":
reset_admin_password()