Hi, wie kann ich in Python eine MySQL Query stoppen wenn die Abfrage über z.B.: 10 sekunden dauert?
1 | import pymysql |
2 | |
3 | db = pymysql.connect(host='xxx', port=3306, user='xxx', passwd='xxx', db='xxx') |
4 | |
5 | cursor = db.cursor() |
6 | |
7 | try: |
8 | cursor.execute("SELECT a.id FROM accounts a limit 1;") |
9 | ## timeoutregel 10 sekunden
|
10 | except: |
11 | print("abgebrochen, hat zu lange gedauert") |
12 | |
13 | print(cursor.fetchall()) |
14 | |
15 | db.close() |