From c21cb0bdfd8efe3bc11fec2de7552c2d3ddabae3 Mon Sep 17 00:00:00 2001 From: hubobel Date: Thu, 24 Jul 2025 15:50:32 +0200 Subject: [PATCH 1/3] ... --- Pool_old/Lotto2SQL_V2.py | 3 +++ lotto2py.py | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Pool_old/Lotto2SQL_V2.py b/Pool_old/Lotto2SQL_V2.py index 1e7ff8d..830c159 100644 --- a/Pool_old/Lotto2SQL_V2.py +++ b/Pool_old/Lotto2SQL_V2.py @@ -91,6 +91,9 @@ if 'Samstag,' in datum: resp = cursor.execute(sql_q) if resp == 0: cursor.execute(sql) + connection.commit() + cursor.close() + connection.close() if 'Mittwoch,' in datum: sql = "INSERT INTO `mittwoch`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `z6`, `sz`, `super6`, `spiel77`) VALUES" \ diff --git a/lotto2py.py b/lotto2py.py index 9354d40..bf155df 100644 --- a/lotto2py.py +++ b/lotto2py.py @@ -193,21 +193,57 @@ def SQLfreitag(data): resp = cursor.execute(sql_q) if resp == 0: cursor.execute(sql) - print(resp) + + connection.commit() + cursor.close() + connection.close() +def SQLsamstag(data): + connection = pymysql.connect(db="hubobel", + user="hubobel", + passwd="polier2003", + host='10.0.1.123', charset='utf8') + cursor = connection.cursor() + sql = "INSERT INTO `samstag`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `z6`, `sz`, `super6`, `spiel77`) VALUES" \ + " ('" + str(data['Datum']) + "','" + str(data['Z1']) + "','" + str(data['Z2']) + "','" + str(data['Z3']) + \ + "','" + str(data['Z4']) + "','" + str(data['Z5']) + "','" + str(data['Z6']) + "','" + str(data['Superzahl']) + \ + "','" + 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 SQLmittwoch(data): + connection = pymysql.connect(db="hubobel", + user="hubobel", + passwd="polier2003", + host='10.0.1.123', charset='utf8') + cursor = connection.cursor() + sql = "INSERT INTO `mittwoch`(`datum`, `z1`, `z2`, `z3`, `z4`, `z5`, `z6`, `sz`, `super6`, `spiel77`) VALUES" \ + " ('" + str(data['Datum']) + "','" + str(data['Z1']) + "','" + str(data['Z2']) + "','" + str(data['Z3']) + \ + "','" + str(data['Z4']) + "','" + str(data['Z5']) + "','" + str(data['Z6']) + "','" + str(data['Superzahl']) + \ + "','" + 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() wochentag = datetime.today().weekday() -wochentag = 1 +wochentag = 2 if wochentag == 2: Zahl = Normalziehung(582) SQLnorm(Zahl) + SQLmittwoch(Zahl) notify_telegram(str(Zahl)) elif wochentag == 5: Zahl = Normalziehung(581) SQLnorm(Zahl) + SQLsamstag(Zahl) notify_telegram(str(Zahl)) elif wochentag == 1: Zahl = Euro() From fc1ae86be7f7d976db7f8a1056cc23a050526f4b Mon Sep 17 00:00:00 2001 From: hubobel Date: Thu, 24 Jul 2025 16:11:16 +0200 Subject: [PATCH 2/3] =?UTF-8?q?.conf=20eingef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lotto2py.py | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/lotto2py.py b/lotto2py.py index bf155df..b8be1a1 100644 --- a/lotto2py.py +++ b/lotto2py.py @@ -3,10 +3,41 @@ from bs4 import BeautifulSoup import re from datetime import datetime import pymysql +import json +import os +import sys -telegram_chat_id = "322673713" -telegram_token ='680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4' +def conf(): + appname = os.path.basename(sys.argv[0]) + appname = appname.replace(".py", ".conf") + absFilePath = os.path.abspath(__file__) + absFilePath = absFilePath.replace(".py", ".conf") + if os.path.isfile(absFilePath) is False: + print(appname + ' scheint es nicht zu geben.') + print('Ich lege eine neue Datei ' + appname + ' an.') + passw = {'mail': + { + "mail_pass": "", + "mail_user": "", + "mail_host": "", + "mail_folder": "" + }, + 'Telegram': + { + "Chat_ID": "", + "TOKEN": "" + } + } + + print(str(appname) + ' bitte entsprechend befüllen.') + with open(absFilePath, 'w') as fp: + json.dump(passw, fp, sort_keys=True, indent=4) + quit() + else: + with open(absFilePath) as file: + passw = json.load(file) + return passw def notify_telegram(text): params = {"parse_mode": "HTML", "chat_id": telegram_chat_id, "text": text} url = f"https://api.telegram.org/bot{telegram_token}/sendMessage" @@ -232,6 +263,10 @@ def SQLmittwoch(data): cursor.close() connection.close() +passw = conf() +telegram_chat_id = passw['Telegram']['Chat_ID'] +telegram_token = passw['Telegram']['TOKEN'] + wochentag = datetime.today().weekday() wochentag = 2 From 59187e891cd05c8d8d4409215d6c9b771ae90c13 Mon Sep 17 00:00:00 2001 From: hubobel Date: Thu, 24 Jul 2025 16:12:51 +0200 Subject: [PATCH 3/3] =?UTF-8?q?.conf=20eingef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lotto2py.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lotto2py.conf diff --git a/lotto2py.conf b/lotto2py.conf new file mode 100644 index 0000000..6ddbcae --- /dev/null +++ b/lotto2py.conf @@ -0,0 +1,12 @@ +{ + "Telegram": { + "Chat_ID": "322673713", + "TOKEN": "680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4" + }, + "mail": { + "mail_folder": "", + "mail_host": "", + "mail_pass": "", + "mail_user": "" + } +} \ No newline at end of file