updated control access
This commit is contained in:
53
old code/backup_db_scripts/find_users_databases.py
Executable file
53
old code/backup_db_scripts/find_users_databases.py
Executable file
@@ -0,0 +1,53 @@
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
def check_database(db_path, description):
|
||||
"""Check if a database exists and show its users."""
|
||||
if os.path.exists(db_path):
|
||||
print(f"\n{description}: FOUND at {db_path}")
|
||||
try:
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Check if users table exists
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='users'")
|
||||
if cursor.fetchone():
|
||||
cursor.execute("SELECT id, username, password, role FROM users")
|
||||
users = cursor.fetchall()
|
||||
if users:
|
||||
print("Users in this database:")
|
||||
for user in users:
|
||||
print(f" ID: {user[0]}, Username: {user[1]}, Password: {user[2]}, Role: {user[3]}")
|
||||
else:
|
||||
print(" Users table exists but is empty")
|
||||
else:
|
||||
print(" No users table found")
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
print(f" Error reading database: {e}")
|
||||
else:
|
||||
print(f"\n{description}: NOT FOUND at {db_path}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Check different possible locations for users.db
|
||||
|
||||
# 1. Root quality_recticel/instance/users.db
|
||||
root_instance = "/home/ske087/quality_recticel/instance/users.db"
|
||||
check_database(root_instance, "Root instance users.db")
|
||||
|
||||
# 2. App instance folder
|
||||
app_instance = "/home/ske087/quality_recticel/py_app/instance/users.db"
|
||||
check_database(app_instance, "App instance users.db")
|
||||
|
||||
# 3. Current working directory
|
||||
cwd_db = "/home/ske087/quality_recticel/py_app/users.db"
|
||||
check_database(cwd_db, "Working directory users.db")
|
||||
|
||||
# 4. Flask app database (relative to py_app)
|
||||
flask_db = "/home/ske087/quality_recticel/py_app/app/users.db"
|
||||
check_database(flask_db, "Flask app users.db")
|
||||
|
||||
print("\n" + "="*50)
|
||||
print("RECOMMENDATION:")
|
||||
print("The login should use the external MariaDB database.")
|
||||
print("Make sure you have created the superadmin user in MariaDB using create_roles_table.py")
|
||||
Reference in New Issue
Block a user