You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
853 B
31 lines
853 B
import json |
|
import pymysql |
|
|
|
new = { |
|
'id': '2023015', |
|
'date': '2023-02-12', |
|
'red': '["02", "03", "14", "21", "29", "32"]', |
|
'blue': '08' |
|
} |
|
|
|
db = { |
|
'host': 'home.rogersun.online', |
|
'user': 'root', |
|
'password': 'Sxzgx1209', |
|
'database': 'lottery' |
|
} |
|
|
|
conn = pymysql.connect(**db) |
|
cursor = conn.cursor() |
|
# with open('num_new.txt', 'r') as f: |
|
# lines = f.readlines() |
|
# for line in lines: |
|
# j = json.loads(line) |
|
# print(j) |
|
# cursor.execute('INSERT INTO history (`dateId`,`openDate`,`red`,`blue`) VALUES (%s,%s,%s,%s)', |
|
# (j['id'], j['date'], json.dumps(j['red']), j['blue'])) |
|
# f.close() |
|
cursor.execute('INSERT INTO history (`dateId`,`openDate`,`red`,`blue`) VALUES (%s,%s,%s,%s)', |
|
(new['id'], new['date'], new['red'], new['blue'])) |
|
cursor.close() |
|
conn.commit()
|
|
|