- Объединены три проекта в один репозиторий - LichessWebServices - REST API для статистики - LichessClientTG_bot - Telegram бот с поддержкой множества пользователей - LichessWebView - Веб-интерфейс для просмотра пользователей и игроков - Добавлен общий docker-compose.yml для запуска всех сервисов - Добавлен скрипт start.sh для удобного запуска - Добавлен README с полным описанием проекта
79 lines
3.3 KiB
Python
79 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
||
import sqlite3
|
||
import json
|
||
from datetime import datetime
|
||
|
||
def view_database():
|
||
"""View database contents"""
|
||
db_path = "data/lichess_bot.db"
|
||
|
||
try:
|
||
with sqlite3.connect(db_path) as conn:
|
||
cursor = conn.cursor()
|
||
|
||
print("🗄️ СОДЕРЖИМОЕ БАЗЫ ДАННЫХ LICHESS BOT")
|
||
print("=" * 50)
|
||
|
||
# Show tables
|
||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
||
tables = cursor.fetchall()
|
||
print(f"\n📋 Таблицы в базе: {[table[0] for table in tables]}")
|
||
|
||
# Show gamers table
|
||
print("\n👥 ТАБЛИЦА GAMERS:")
|
||
print("-" * 30)
|
||
cursor.execute("SELECT * FROM gamers")
|
||
gamers = cursor.fetchall()
|
||
|
||
if gamers:
|
||
print("ID | Username | Token | Active | Period | User ID | Created")
|
||
print("-" * 70)
|
||
for gamer in gamers:
|
||
if len(gamer) == 6: # Old format without user_id
|
||
gamer_id, username, token, is_active, period_minutes, created_at = gamer
|
||
user_id = "None"
|
||
else: # New format with user_id
|
||
gamer_id, username, token, is_active, period_minutes, user_id, created_at = gamer
|
||
|
||
token_display = "***" if token else "None"
|
||
active_display = "✅" if is_active else "❌"
|
||
user_id_display = str(user_id) if user_id else "None"
|
||
print(f"{gamer_id:2} | {username:10} | {token_display:6} | {active_display:6} | {period_minutes:6} | {user_id_display:7} | {created_at}")
|
||
else:
|
||
print("Таблица пуста")
|
||
|
||
# Show chat_active_gamers table
|
||
print("\n💬 ТАБЛИЦА CHAT_ACTIVE_GAMERS:")
|
||
print("-" * 35)
|
||
cursor.execute("SELECT * FROM chat_active_gamers")
|
||
chat_gamers = cursor.fetchall()
|
||
|
||
if chat_gamers:
|
||
print("Chat ID | Gamer ID")
|
||
print("-" * 20)
|
||
for chat_gamer in chat_gamers:
|
||
chat_id, gamer_id = chat_gamer
|
||
print(f"{chat_id:7} | {gamer_id:8}")
|
||
else:
|
||
print("Таблица пуста")
|
||
|
||
# Show database info
|
||
print(f"\n📊 ИНФОРМАЦИЯ О БАЗЕ:")
|
||
print("-" * 25)
|
||
cursor.execute("SELECT COUNT(*) FROM gamers")
|
||
total_gamers = cursor.fetchone()[0]
|
||
print(f"Всего игроков: {total_gamers}")
|
||
|
||
cursor.execute("SELECT COUNT(*) FROM gamers WHERE is_active = TRUE")
|
||
active_gamers = cursor.fetchone()[0]
|
||
print(f"Активных игроков: {active_gamers}")
|
||
|
||
cursor.execute("SELECT COUNT(*) FROM gamers WHERE period_minutes > 0")
|
||
monitored_gamers = cursor.fetchone()[0]
|
||
print(f"Игроков с периодическими уведомлениями: {monitored_gamers}")
|
||
|
||
except Exception as e:
|
||
print(f"❌ Ошибка при чтении базы данных: {e}")
|
||
|
||
if __name__ == "__main__":
|
||
view_database()
|