-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_test_users.py
More file actions
32 lines (24 loc) · 1.47 KB
/
Copy pathdelete_test_users.py
File metadata and controls
32 lines (24 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import asyncio
import aiosqlite
from config import DATABASE_PATH
async def delete_test_users():
# ID пользователей, которых нужно удалить
user_ids = [34975055, 7059952799]
try:
async with aiosqlite.connect(DATABASE_PATH) as db:
# Удаляем уведомления
await db.execute(f"DELETE FROM notifications WHERE user_id IN ({','.join(map(str, user_ids))})")
# Удаляем оценки
await db.execute(f"DELETE FROM grades WHERE student_id IN ({','.join(map(str, user_ids))})")
# Удаляем записи о посещаемости
await db.execute(f"DELETE FROM attendance WHERE student_id IN ({','.join(map(str, user_ids))})")
# Удаляем самих пользователей
await db.execute(f"DELETE FROM users WHERE telegram_id IN ({','.join(map(str, user_ids))})")
# Сохраняем изменения
await db.commit()
print(f"Пользователи с ID {', '.join(map(str, user_ids))} успешно удалены!")
print("Теперь вы можете заново зарегистрировать этих пользователей в боте.")
except Exception as e:
print(f"Произошла ошибка: {e}")
if __name__ == "__main__":
asyncio.run(delete_test_users())