From 2c85531360190c475c6eb4eaece353b8e89adebc Mon Sep 17 00:00:00 2001 From: hubobel Date: Thu, 16 Oct 2025 16:06:28 +0200 Subject: [PATCH] =?UTF-8?q?Fehler=20behoben:=20Es=20werden=20alle=20gezoge?= =?UTF-8?q?nen=20Zahlen=20gepr=C3=BCft,=20ob=20Kombi=20bereits=20in=20db?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lotto2py.py | 103 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 32 deletions(-) diff --git a/lotto2py.py b/lotto2py.py index e87357e..3b6e312 100644 --- a/lotto2py.py +++ b/lotto2py.py @@ -205,7 +205,6 @@ def SQLnorm(data): connection.commit() cursor.close() connection.close() - def SQLdienstag(data): connection = pymysql.connect(db="hubobel", user="hubobel", @@ -220,7 +219,7 @@ def SQLdienstag(data): data['Eurozahl2']) + "')" sql_q = "SELECT * FROM euro WHERE datum like '%" + data['Datum'] + "%'" resp = cursor.execute(sql_q) - if resp == 0: + if test == 0: cursor.execute(sql) notify_telegram(str(data)) #print(resp) @@ -276,61 +275,101 @@ def SQLmittwoch(data): "','" + str(data['Super6']) + "','" + str(data['Spiel77']) + "')" sql_q = "SELECT * FROM samstag WHERE datum like '%" + data['Datum'] + "%'" resp = cursor.execute(sql_q) + if resp == 0: cursor.execute(sql) connection.commit() cursor.close() connection.close() +def SQLtesteuro(data): + print(data) + connection = pymysql.connect( + host='10.0.1.123', + user='hubobel', + password='polier2003', + database='hubobel', + charset='utf8mb4', + cursorclass=pymysql.cursors.Cursor + ) -def datum(): - sql = """UPDATE `6aus49` -SET datum = DATE_FORMAT( - COALESCE( - STR_TO_DATE(TRIM(SUBSTRING_INDEX(datum, '/', -1)), '%d.%m.%Y'), - STR_TO_DATE(TRIM(SUBSTRING_INDEX(datum, '/', -1)), '%d.%m.%y') - ), - '%Y-%m-%d' -) -WHERE - COALESCE( - STR_TO_DATE(TRIM(SUBSTRING_INDEX(datum, '/', -1)), '%d.%m.%Y'), - STR_TO_DATE(TRIM(SUBSTRING_INDEX(datum, '/', -1)), '%d.%m.%y') - ) IS NOT NULL;""" - connection = pymysql.connect(db="hubobel", - user="hubobel", - passwd="polier2003", - host='10.0.1.123', charset='utf8') - cursor = connection.cursor() - cursor.execute(sql) - connection.commit() - cursor.close() - connection.close() + try: + with connection.cursor() as cursor: + # Beispielwerte + z1, z2, z3, z4, z5 = data['Z1'], data['Z2'],data['Z3'],data['Z4'],data['Z5'] + sql_check = """ + SELECT 1 FROM `euro` + WHERE z1 = %s AND z2 = %s AND z3 = %s AND z4 = %s AND z5 = %s + LIMIT 1 + """ + cursor.execute(sql_check, (z1, z2, z3, z4, z5)) + exists = cursor.fetchone() is not None + if exists: + print("✅ Kombination existiert bereits.") + a = 1 + else: + print("🆕 Kombination ist neu – kann eingefügt werden.") + a = 0 + + finally: + connection.close() + return a +def SQLtestsechs(data): + print(data) + connection = pymysql.connect( + host='10.0.1.123', + user='hubobel', + password='polier2003', + database='hubobel', + charset='utf8mb4', + cursorclass=pymysql.cursors.Cursor + ) + + try: + with connection.cursor() as cursor: + # Beispielwerte + z1, z2, z3, z4, z5, z6 = data['Z1'], data['Z2'],data['Z3'],data['Z4'],data['Z5'],data['Z6'] + sql_check = """ + SELECT 1 FROM `6aus49` + WHERE z1 = %s AND z2 = %s AND z3 = %s AND z4 = %s AND z5 = %s AND z6 = %s + LIMIT 1 + """ + cursor.execute(sql_check, (z1, z2, z3, z4, z5, z6)) + exists = cursor.fetchone() is not None + + if exists: + print("✅ Kombination existiert bereits.") + a = 1 + else: + print("🆕 Kombination ist neu – kann eingefügt werden.") + a = 0 + + finally: + connection.close() + return a passw = conf() telegram_chat_id = passw['Telegram']['Chat_ID'] telegram_token = passw['Telegram']['TOKEN'] wochentag = datetime.today().weekday() -#wochentag = 5 +#wochentag = 2 if wochentag == 2: Zahl = Normalziehung(582) + test = SQLtestsechs(Zahl) SQLnorm(Zahl) - SQLmittwoch(Zahl) - #notify_telegram(str(Zahl)) elif wochentag == 5: Zahl = Normalziehung(581) + test = SQLtestsechs(Zahl) SQLnorm(Zahl) - SQLsamstag(Zahl) - #notify_telegram(str(Zahl)) elif wochentag == 1: Zahl = Euro() + test = SQLtesteuro(Zahl['Dienstag']) SQLdienstag(Zahl['Dienstag']) - #notify_telegram(str(Zahl['Dienstag'])) elif wochentag == 4: Zahl = Euro() + test = SQLtesteuro(Zahl['Freitag']) SQLfreitag(Zahl['Freitag']) - #notify_telegram(str(Zahl['Freitag'])) else: quit()