Modularización de GKACHELE SaaS
This commit is contained in:
78
demo/ver_usuarios.py
Normal file
78
demo/ver_usuarios.py
Normal file
@@ -0,0 +1,78 @@
|
||||
"""
|
||||
GKACHELE™ - Script para ver usuarios registrados
|
||||
© 2025 GKACHELE™. Todos los derechos reservados.
|
||||
Uso: python ver_usuarios.py
|
||||
"""
|
||||
|
||||
import sqlite3
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
# Ruta de la base de datos
|
||||
BASE_DIR = os.path.dirname(__file__)
|
||||
DATABASE_DIR = os.path.join(BASE_DIR, 'database')
|
||||
MAIN_DB = os.path.join(DATABASE_DIR, 'main.db')
|
||||
|
||||
def ver_usuarios():
|
||||
"""Ver todos los usuarios registrados"""
|
||||
if not os.path.exists(MAIN_DB):
|
||||
print(f"❌ No se encontró la base de datos en: {MAIN_DB}")
|
||||
return
|
||||
|
||||
try:
|
||||
conn = sqlite3.connect(MAIN_DB)
|
||||
c = conn.cursor()
|
||||
|
||||
# Obtener usuarios
|
||||
c.execute('SELECT id, email, plan, rubro, created_at FROM users ORDER BY id')
|
||||
users = c.fetchall()
|
||||
|
||||
if not users:
|
||||
print("📭 No hay usuarios registrados aún")
|
||||
return
|
||||
|
||||
print("=" * 80)
|
||||
print("👥 USUARIOS REGISTRADOS")
|
||||
print("=" * 80)
|
||||
print(f"{'ID':<5} {'Email':<35} {'Plan':<10} {'Rubro':<15} {'Fecha Registro':<20}")
|
||||
print("-" * 80)
|
||||
|
||||
for user in users:
|
||||
user_id, email, plan, rubro, created_at = user
|
||||
# Formatear fecha
|
||||
fecha = created_at if created_at else 'N/A'
|
||||
print(f"{user_id:<5} {email:<35} {plan:<10} {rubro:<15} {fecha:<20}")
|
||||
|
||||
print("-" * 80)
|
||||
print(f"Total: {len(users)} usuario(s)")
|
||||
|
||||
# Obtener sitios por usuario
|
||||
print("\n" + "=" * 80)
|
||||
print("🌐 SITIOS POR USUARIO")
|
||||
print("=" * 80)
|
||||
|
||||
for user in users:
|
||||
user_id, email, plan, rubro, created_at = user
|
||||
c.execute('SELECT id, slug, theme, status, created_at FROM sites WHERE user_id = ? ORDER BY id', (user_id,))
|
||||
sites = c.fetchall()
|
||||
|
||||
print(f"\n👤 Usuario ID {user_id} ({email}):")
|
||||
if sites:
|
||||
print(f" {'ID':<5} {'Slug':<25} {'Tema':<20} {'Estado':<12} {'Fecha':<20}")
|
||||
print(" " + "-" * 82)
|
||||
for site in sites:
|
||||
site_id, slug, theme, status, site_created = site
|
||||
fecha = site_created if site_created else 'N/A'
|
||||
print(f" {site_id:<5} {slug:<25} {theme:<20} {status:<12} {fecha:<20}")
|
||||
else:
|
||||
print(" ⚠️ No tiene sitios creados")
|
||||
|
||||
conn.close()
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if __name__ == '__main__':
|
||||
ver_usuarios()
|
||||
Reference in New Issue
Block a user