Fehler behoben: Es werden alle gezogenen Zahlen geprüft, ob Kombi bereits in db

This commit is contained in:
hubobel 2025-10-16 16:06:28 +02:00
parent 88eabe4613
commit 2c85531360

View file

@ -205,7 +205,6 @@ def SQLnorm(data):
connection.commit() connection.commit()
cursor.close() cursor.close()
connection.close() connection.close()
def SQLdienstag(data): def SQLdienstag(data):
connection = pymysql.connect(db="hubobel", connection = pymysql.connect(db="hubobel",
user="hubobel", user="hubobel",
@ -220,7 +219,7 @@ def SQLdienstag(data):
data['Eurozahl2']) + "')" data['Eurozahl2']) + "')"
sql_q = "SELECT * FROM euro WHERE datum like '%" + data['Datum'] + "%'" sql_q = "SELECT * FROM euro WHERE datum like '%" + data['Datum'] + "%'"
resp = cursor.execute(sql_q) resp = cursor.execute(sql_q)
if resp == 0: if test == 0:
cursor.execute(sql) cursor.execute(sql)
notify_telegram(str(data)) notify_telegram(str(data))
#print(resp) #print(resp)
@ -276,61 +275,101 @@ def SQLmittwoch(data):
"','" + str(data['Super6']) + "','" + str(data['Spiel77']) + "')" "','" + str(data['Super6']) + "','" + str(data['Spiel77']) + "')"
sql_q = "SELECT * FROM samstag WHERE datum like '%" + data['Datum'] + "%'" sql_q = "SELECT * FROM samstag WHERE datum like '%" + data['Datum'] + "%'"
resp = cursor.execute(sql_q) resp = cursor.execute(sql_q)
if resp == 0: if resp == 0:
cursor.execute(sql) cursor.execute(sql)
connection.commit() connection.commit()
cursor.close() cursor.close()
connection.close() connection.close()
def SQLtesteuro(data):
def datum(): print(data)
sql = """UPDATE `6aus49` connection = pymysql.connect(
SET datum = DATE_FORMAT( host='10.0.1.123',
COALESCE( user='hubobel',
STR_TO_DATE(TRIM(SUBSTRING_INDEX(datum, '/', -1)), '%d.%m.%Y'), password='polier2003',
STR_TO_DATE(TRIM(SUBSTRING_INDEX(datum, '/', -1)), '%d.%m.%y') database='hubobel',
), charset='utf8mb4',
'%Y-%m-%d' cursorclass=pymysql.cursors.Cursor
) )
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() passw = conf()
telegram_chat_id = passw['Telegram']['Chat_ID'] telegram_chat_id = passw['Telegram']['Chat_ID']
telegram_token = passw['Telegram']['TOKEN'] telegram_token = passw['Telegram']['TOKEN']
wochentag = datetime.today().weekday() wochentag = datetime.today().weekday()
#wochentag = 5 #wochentag = 2
if wochentag == 2: if wochentag == 2:
Zahl = Normalziehung(582) Zahl = Normalziehung(582)
test = SQLtestsechs(Zahl)
SQLnorm(Zahl) SQLnorm(Zahl)
SQLmittwoch(Zahl)
#notify_telegram(str(Zahl))
elif wochentag == 5: elif wochentag == 5:
Zahl = Normalziehung(581) Zahl = Normalziehung(581)
test = SQLtestsechs(Zahl)
SQLnorm(Zahl) SQLnorm(Zahl)
SQLsamstag(Zahl)
#notify_telegram(str(Zahl))
elif wochentag == 1: elif wochentag == 1:
Zahl = Euro() Zahl = Euro()
test = SQLtesteuro(Zahl['Dienstag'])
SQLdienstag(Zahl['Dienstag']) SQLdienstag(Zahl['Dienstag'])
#notify_telegram(str(Zahl['Dienstag']))
elif wochentag == 4: elif wochentag == 4:
Zahl = Euro() Zahl = Euro()
test = SQLtesteuro(Zahl['Freitag'])
SQLfreitag(Zahl['Freitag']) SQLfreitag(Zahl['Freitag'])
#notify_telegram(str(Zahl['Freitag']))
else: else:
quit() quit()