-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_admin.py
More file actions
26 lines (23 loc) · 813 Bytes
/
Copy pathcheck_admin.py
File metadata and controls
26 lines (23 loc) · 813 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
import mysql.connector
try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database="medimind"
)
cursor = conn.cursor(dictionary=True)
cursor.execute("SELECT * FROM admins LIMIT 1")
admin = cursor.fetchone()
if admin:
print(f"Admin found: {admin['email']}")
else:
print("No admin found. Creating one...")
from werkzeug.security import generate_password_hash
hashed = generate_password_hash("admin123")
cursor.execute("INSERT INTO admins (name, email, password) VALUES (%s, %s, %s)", ("Admin", "admin@medimind.com", hashed))
conn.commit()
print("Admin created: admin@medimind.com / admin123")
conn.close()
except Exception as e:
print(f"Error: {e}")