31 lines
852 B
Python
Executable File
31 lines
852 B
Python
Executable File
import sqlite3
|
|
import os
|
|
|
|
instance_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../instance'))
|
|
db_path = os.path.join(instance_folder, 'users.db')
|
|
|
|
if not os.path.exists(db_path):
|
|
print("users.db not found at", db_path)
|
|
exit(1)
|
|
|
|
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 not cursor.fetchone():
|
|
print("No users table found in users.db.")
|
|
conn.close()
|
|
exit(1)
|
|
|
|
# Print all users
|
|
cursor.execute("SELECT id, username, password, role FROM users")
|
|
rows = cursor.fetchall()
|
|
if not rows:
|
|
print("No users found in users.db.")
|
|
else:
|
|
print("Users in users.db:")
|
|
for row in rows:
|
|
print(f"id={row[0]}, username={row[1]}, password={row[2]}, role={row[3]}")
|
|
conn.close()
|