|
|
@ -117,6 +117,15 @@ def get_red_forecast(_all_data, _red_data_dict, _red_data, range_num=1): |
|
|
|
return _red_forecast_dict, _red_forecast_list |
|
|
|
return _red_forecast_dict, _red_forecast_list |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_last_date_id(): |
|
|
|
|
|
|
|
conn = pymysql.connect(**db) |
|
|
|
|
|
|
|
curser = conn.cursor(DictCursor) |
|
|
|
|
|
|
|
curser.execute("SELECT * FROM history ORDER BY id DESC LIMIT 1") |
|
|
|
|
|
|
|
_data = curser.fetchone() |
|
|
|
|
|
|
|
# print(all_data) |
|
|
|
|
|
|
|
return _data['dateId'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_red_forecast_db(): |
|
|
|
def update_red_forecast_db(): |
|
|
|
all_data = get_all_data() |
|
|
|
all_data = get_all_data() |
|
|
|
red_data = get_all_red() |
|
|
|
red_data = get_all_red() |
|
|
@ -128,12 +137,17 @@ def update_red_forecast_db(): |
|
|
|
red_suggest = json.dumps(sorted(red_forecast_list[0:6])) |
|
|
|
red_suggest = json.dumps(sorted(red_forecast_list[0:6])) |
|
|
|
conn = pymysql.connect(**db) |
|
|
|
conn = pymysql.connect(**db) |
|
|
|
curser = conn.cursor(DictCursor) |
|
|
|
curser = conn.cursor(DictCursor) |
|
|
|
curser.execute() |
|
|
|
last_date_id = get_last_date_id() |
|
|
|
curser.execute( |
|
|
|
curser.execute("SELECT * FROM lottery.red_forecast WHERE dateId = %s", (last_date_id, )) |
|
|
|
"INSERT INTO lottery.red_forecast (`dateId`, `params`, `red_rate`, `red_suggest`) VALUES (%s, %s, %s, %s)", |
|
|
|
have_duplicate = False if len(curser.fetchall()) == 0 else True |
|
|
|
(date_id, params, red_rate, red_suggest)) |
|
|
|
if not have_duplicate: |
|
|
|
conn.commit() |
|
|
|
curser.execute( |
|
|
|
curser.close() |
|
|
|
"INSERT INTO lottery.red_forecast (`dateId`, `params`, `red_rate`, `red_suggest`) VALUES (%s, %s, %s, %s)", |
|
|
|
|
|
|
|
(date_id, params, red_rate, red_suggest)) |
|
|
|
|
|
|
|
conn.commit() |
|
|
|
|
|
|
|
curser.close() |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
print('数据库中有重复记录,无需重复插入') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|