import sqlite3 from API.rok import get_order_content import requests # from send_mai import send_html_flow conn = sqlite3.connect("./files/rokky.db") cursor = conn.cursor() def rok_orders(): conn = sqlite3.connect("./files/rokky.db") cursor = conn.cursor() cursor.execute(""" SELECT * FROM orders WHERE key IS NULL OR key = '' """) rows = cursor.fetchall() for row in rows: order_id = row[12] # ✅ id (а не 12!) id_i = row[1] print(f"Обработка заказа {order_id}") try: # пример: new_key = get_order_content(int(order_id)) cursor.execute(""" UPDATE orders SET key = ? WHERE id = ? """, (new_key, order_id)) url = "https://wstkeys.top/newOrder" # url = "http://0.0.0.0:5205/newOrder" payload = {"orderId": int(order_id), "partnerSchemaId": 209} headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) except Exception as a: print(a) print(response.status_code) print(response.text) conn.commit() conn.close()