29 lines
774 B
Python
29 lines
774 B
Python
#!/usr/bin/env python3
|
|
|
|
import pymysql
|
|
|
|
try:
|
|
# Connect to the database
|
|
conn = pymysql.connect(
|
|
host='localhost',
|
|
database='trasabilitate',
|
|
user='trasabilitate',
|
|
password='Initial01!',
|
|
cursorclass=pymysql.cursors.DictCursor
|
|
)
|
|
|
|
with conn.cursor() as cursor:
|
|
cursor.execute("SELECT id, username, role, modules FROM users")
|
|
users = cursor.fetchall()
|
|
|
|
print("Current users in database:")
|
|
print("-" * 50)
|
|
for user in users:
|
|
print(f"ID: {user['id']}")
|
|
print(f"Username: {user['username']}")
|
|
print(f"Role: {user['role']}")
|
|
print(f"Modules: {user['modules']}")
|
|
print("-" * 30)
|
|
|
|
finally:
|
|
conn.close() |