Fehler behoben: Es werden alle gezogenen Zahlen geprüft, ob Kombi bereits in db
This commit is contained in:
parent
88eabe4613
commit
2c85531360
1 changed files with 71 additions and 32 deletions
103
lotto2py.py
103
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue