""" Скрипт для создания резервов для существующих заказов """ import os import django os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings') django.setup() from django.db import connection # Читаем SQL скрипт with open('fix_reservations.sql', 'r', encoding='utf-8') as f: sql = f.read() # Выполняем SQL with connection.cursor() as cursor: try: cursor.execute(sql) print("[OK] SQL script executed successfully!") print("\nResults:") # Получаем результат последнего SELECT rows = cursor.fetchall() if rows: row = rows[0] print(f" Total items: {row[0]}") print(f" Items with reservations: {row[1]}") print(f" Items without reservations: {row[2]}") print("\n[OK] Reservations created!") except Exception as e: print(f"[ERROR] {e}") raise