| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import mysql.connector
- from decimal import Decimal
- import datetime
- DB_CONFIG = {
- 'user': 'root',
- 'password': '84853032',
- 'host': '47.99.60.80',
- 'port': 3306,
- 'database': '2022hs060',
- 'use_pure': True,
- 'connect_timeout': 5
- }
- def check_schema():
- try:
- conn = mysql.connector.connect(**DB_CONFIG)
- cursor = conn.cursor(dictionary=True)
-
- # 1. Check mp_measure_order columns
- print("=== mp_measure_order Columns ===")
- cursor.execute("DESCRIBE mp_measure_order")
- cols = cursor.fetchall()
- for col in cols:
- print(f"{col['Field']} - {col['Type']}")
- # 2. Check mp_construction_measure_others columns
- print("\n=== mp_construction_measure_others Columns ===")
- cursor.execute("DESCRIBE mp_construction_measure_others")
- cols = cursor.fetchall()
- for col in cols:
- print(f"{col['Field']} - {col['Type']}")
- # 2.1 Check mp_contract columns
- print("\n=== mp_contract Columns ===")
- cursor.execute("DESCRIBE mp_contract")
- cols = cursor.fetchall()
- for col in cols:
- print(f"{col['Field']} - {col['Type']}")
-
- # 3. Sample data from mp_construction_measure_others for a completed order
- print("\n=== Sample Data from mp_construction_measure_others (Limit 20) ===")
- cursor.execute("SELECT id FROM mp_measure_order WHERE status=2 LIMIT 1")
- order = cursor.fetchone()
- if order:
- print(f"Order ID: {order['id']}")
- # CORRECT COLUMN NAME: mp_construction_measure_id
- cursor.execute(f"SELECT name, construction_measure_amount, end_current_period_amount FROM mp_construction_measure_others WHERE mp_construction_measure_id = '{order['id']}'")
- rows = cursor.fetchall()
- for row in rows:
- print(row)
-
- conn.close()
- except Exception as e:
- print(e)
- if __name__ == "__main__":
- check_schema()
|