erster SQL Export in die "alte" DB

This commit is contained in:
hubobel 2025-07-14 18:49:39 +02:00
parent 438a3cce43
commit 4f3ff5ad3f

View file

@ -2,6 +2,7 @@ import requests
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import re import re
from datetime import datetime from datetime import datetime
import pymysql
wochentag = datetime.today().weekday() wochentag = datetime.today().weekday()
@ -82,6 +83,13 @@ print("Super 6 :", super6)
lottozahlen.sort() lottozahlen.sort()
ab = 'Z' ab = 'Z'
cd = 1 cd = 1
subber6 =''
game77=''
for i in super6:
subber6 = subber6 + str(i)
for i in spiel77:
game77 = game77 + str(i)
for i in lottozahlen: for i in lottozahlen:
print(i) print(i)
ef=str((ab+str(cd))) ef=str((ab+str(cd)))
@ -89,8 +97,27 @@ for i in lottozahlen:
cd = cd +1 cd = cd +1
Lottozahlen['Datum'] = datum_woche Lottozahlen['Datum'] = datum_woche
Lottozahlen['Superzahl'] = superzahl Lottozahlen['Superzahl'] = superzahl
Lottozahlen['Spiel77'] = spiel77 Lottozahlen['Spiel77'] = int(game77)
Lottozahlen['Super6'] = super6 Lottozahlen['Super6'] = int(subber6)
print(Lottozahlen) print(Lottozahlen)
data = Lottozahlen
connection = pymysql.connect(db="hubobel",
user="hubobel",
passwd="polier2003",
host='10.0.1.123',charset='utf8')
cursor = connection.cursor()
sql = "INSERT INTO `6aus49`(`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 6aus49 WHERE datum like '%" + data['Datum'] + "%'"
resp = cursor.execute(sql_q)
if resp == 0:
cursor.execute(sql)
connection.commit()
cursor.close()
connection.close()
notify_telegram(str(Lottozahlen)) notify_telegram(str(Lottozahlen))