Spaces:
Sleeping
Sleeping
Upload set_admin.py
Browse files- set_admin.py +28 -0
set_admin.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sqlite3
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
# Database path
|
| 5 |
+
DB_PATH = os.path.join(os.path.dirname(__file__), "vortex.db")
|
| 6 |
+
|
| 7 |
+
def set_all_admins():
|
| 8 |
+
if not os.path.exists(DB_PATH):
|
| 9 |
+
print(f"Error: Database not found at {DB_PATH}")
|
| 10 |
+
return
|
| 11 |
+
|
| 12 |
+
try:
|
| 13 |
+
conn = sqlite3.connect(DB_PATH)
|
| 14 |
+
cursor = conn.cursor()
|
| 15 |
+
|
| 16 |
+
# Update all users to admin role for development
|
| 17 |
+
cursor.execute("UPDATE users SET role = 'admin'")
|
| 18 |
+
conn.commit()
|
| 19 |
+
|
| 20 |
+
updated_count = cursor.rowcount
|
| 21 |
+
print(f"Successfully updated {updated_count} users to ADMIN role.")
|
| 22 |
+
|
| 23 |
+
conn.close()
|
| 24 |
+
except Exception as e:
|
| 25 |
+
print(f"An error occurred: {e}")
|
| 26 |
+
|
| 27 |
+
if __name__ == "__main__":
|
| 28 |
+
set_all_admins()
|