check_bq.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import mysql.connector
  2. from decimal import Decimal
  3. import datetime
  4. DB_CONFIG = {
  5. 'user': 'root',
  6. 'password': '84853032',
  7. 'host': '47.99.60.80',
  8. 'port': 3306,
  9. 'database': '2022hs060',
  10. 'use_pure': True,
  11. 'connect_timeout': 5
  12. }
  13. def check_bq():
  14. try:
  15. conn = mysql.connector.connect(**DB_CONFIG)
  16. cursor = conn.cursor(dictionary=True)
  17. # Check table columns
  18. print("Checking columns of mp_construction_measure_bq:")
  19. cursor.execute("DESCRIBE mp_construction_measure_bq")
  20. cols = cursor.fetchall()
  21. for col in cols:
  22. print(f"{col['Field']} - {col['Type']}")
  23. # Check count for a known completed order
  24. # User provided ID: 1819285928247525377
  25. target_id = '1819285928247525377'
  26. print(f"\nChecking BQs for target order {target_id}:")
  27. cursor.execute(f"SELECT COUNT(*) as cnt FROM mp_construction_measure_bq WHERE mp_measure_id = '{target_id}'")
  28. cnt = cursor.fetchone()
  29. print(f"Count: {cnt['cnt']}")
  30. # Check order existence
  31. cursor.execute(f"SELECT * FROM mp_measure_order WHERE id = '{target_id}'")
  32. order = cursor.fetchone()
  33. if order:
  34. print(f"Order found. Status: {order['status']}")
  35. else:
  36. print("Order NOT found.")
  37. conn.close()
  38. except Exception as e:
  39. print(e)
  40. if __name__ == "__main__":
  41. check_bq()