From bf53722a307356e51d61ef62c875c41ac89460cc Mon Sep 17 00:00:00 2001 From: hubobel Date: Thu, 14 Feb 2019 18:10:52 +0100 Subject: [PATCH] Fehler bei der SQL-Abfrage wird abgefangen --- FilosophieTOsql.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/FilosophieTOsql.py b/FilosophieTOsql.py index 63d4104..148448f 100644 --- a/FilosophieTOsql.py +++ b/FilosophieTOsql.py @@ -40,15 +40,18 @@ while start <= anzahl: print(start,' von ',anzahl) sql = "INSERT INTO `test`(`nr`, `Filosophiefact`) VALUES ('" + str(start) + "','" + filosophie + "')" sql_q = "SELECT * FROM test WHERE Filosophiefact like '%" + str(filosophie) + "%'" - resp = cursor.execute(sql_q) - if resp == 0: - try: - resp = cursor.execute(sql) - except: - print('Es gab ein Problem beim Schreiben des facts in die DB') + + try: + resp = cursor.execute(sql_q) + if resp == 0: + try: + resp = cursor.execute(sql) + except: + print('Es gab ein Problem beim Schreiben des facts in die DB') + except: + None connection.commit() start +=1 - time.sleep(1) cursor.close() connection.close()