"""Reset imported orders in SQLite back to SKIPPED after Oracle deletion""" import sys, sqlite3 sys.stdout.reconfigure(encoding='utf-8', errors='replace') db = sqlite3.connect(r'C:\gomag-vending\api\data\import.db') c = db.cursor() # Show before c.execute("SELECT order_number, customer_name, id_comanda, status FROM orders WHERE status = 'IMPORTED'") rows = c.fetchall() print(f"Orders to reset: {len(rows)}") for r in rows: print(f" {r[0]} | {r[1]} | id_comanda={r[2]} | {r[3]}") # Reset c.execute(""" UPDATE orders SET status = 'SKIPPED', id_comanda = NULL, id_partener = NULL, id_adresa_facturare = NULL, id_adresa_livrare = NULL, error_message = NULL, factura_serie = NULL, factura_numar = NULL, factura_total_fara_tva = NULL, factura_total_tva = NULL, factura_total_cu_tva = NULL, factura_data = NULL, invoice_checked_at = NULL WHERE status = 'IMPORTED' """) print(f"\nReset: {c.rowcount} orders → SKIPPED") db.commit() # Verify c.execute("SELECT status, COUNT(*) FROM orders GROUP BY status") print("\nStatus after reset:") for r in c.fetchall(): print(f" {r[0]:20s} {r[1]}") db.close()