test.py 668 B

1234567891011121314151617181920212223242526272829303132
  1. import pymysql
  2. conn = pymysql.connect(
  3. host='127.0.0.1',
  4. user='root',
  5. password='g53743001',
  6. db='erptest',
  7. charset='utf8'
  8. )
  9. cur5 = conn.cursor()
  10. # 獲取欄位資料
  11. t1 = '乾燥貨櫃'
  12. sql5 = "select DISTINCT 系統 from abc"
  13. sql5 += ' WHERE 產品 = \'' + t1 + '\' '
  14. cur5.execute(sql5)
  15. print(sql5)
  16. labels5 = cur5.fetchall()
  17. labels5 = [g[0] for g in labels5]
  18. print(labels5)
  19. # 獲取欄位資料
  20. t2 = '清洗槽組立'
  21. sql6 = "select DISTINCT 模組圖名 from abc"
  22. sql6 += ' WHERE 系統 = \'' + t2 + '\' '
  23. cur5.execute(sql6)
  24. print(sql6)
  25. labels5 = cur5.fetchall()
  26. labels5 = [g[0] for g in labels5]
  27. print(labels5)