|
|
@@ -0,0 +1,1019 @@
|
|
|
+import datetime
|
|
|
+import hashlib
|
|
|
+import time
|
|
|
+
|
|
|
+# 生成哈希索引 sole
|
|
|
+def hash_func(match_id, odds_code, sort, p_id):
|
|
|
+ m = hashlib.md5()
|
|
|
+ a = str(match_id) + str(odds_code) + str(sort) + str(p_id)
|
|
|
+ m.update(a.encode('utf-8'))
|
|
|
+ c = m.hexdigest()
|
|
|
+ return c
|
|
|
+
|
|
|
+
|
|
|
+# 生成odds_only哈希
|
|
|
+def r_func(match_id, odds_code, sort, p_id, odd):
|
|
|
+ m = hashlib.md5()
|
|
|
+ a = str(match_id) + str(odds_code) + str(sort) + str(p_id) + str(odd)
|
|
|
+ m.update(a.encode('utf-8'))
|
|
|
+ c = m.hexdigest()
|
|
|
+ return c
|
|
|
+
|
|
|
+
|
|
|
+# 转换成本地时间
|
|
|
+def new_time(ctime):
|
|
|
+ time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
|
|
|
+ time2 = time.localtime(time1)
|
|
|
+ time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
|
|
|
+ time4 = time3
|
|
|
+ data_time = str(time4).split(" ")
|
|
|
+ match_date = data_time[0]
|
|
|
+ match_time = data_time[1]
|
|
|
+ return match_date, match_time, time3
|
|
|
+
|
|
|
+
|
|
|
+def out_time(ctime, i):
|
|
|
+ ctime1 = datetime.datetime.strptime(ctime, "%Y-%m-%d %H:%M:%S")
|
|
|
+ n_ctime = (ctime1 + datetime.timedelta(hours=i)).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
+ return n_ctime
|
|
|
+
|
|
|
+
|
|
|
+def fuhao(f):
|
|
|
+ if f.startswith('+'):
|
|
|
+ f = f.replace('+', '-')
|
|
|
+ return f
|
|
|
+ elif f.startswith('-'):
|
|
|
+ f = f.replace('-', '+')
|
|
|
+ return f
|
|
|
+ else:
|
|
|
+ return f
|
|
|
+
|
|
|
+
|
|
|
+# 篮球插入赔率 -----------------------------------------------------------------------------------------------------------
|
|
|
+def one_intodb(data1, data2, data3, cursor, redis_db):
|
|
|
+ if data1:
|
|
|
+ for key, value in data1.items():
|
|
|
+ if value:
|
|
|
+ for x, y in enumerate(value):
|
|
|
+ new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=x, p_id=data2['p_id'])
|
|
|
+ r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=x, p_id=data2['p_id'],odd=y)
|
|
|
+ odds_only = r_hash
|
|
|
+ l_f = fuhao(str(data3[key][x]))
|
|
|
+ if redis_db.hexists("hg3535_lanqiu", r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset("hg3535_lanqiu", r_hash, 0)
|
|
|
+ sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+ cursor.execute(sql1, (
|
|
|
+ int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], y,
|
|
|
+ data2['p_id'], data2["p_code"], x, data2["source"], new_hash,
|
|
|
+ l_f, data2['expire_time'], odds_only,data2['utime'], y, data2['expire_time'],
|
|
|
+ odds_only, l_f))
|
|
|
+ # 更新主队st_zq_odds_record表
|
|
|
+ sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s);"
|
|
|
+ cursor.execute(sql2, (
|
|
|
+ int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], y,
|
|
|
+ data2['p_id'], data2["p_code"], x, data2["source"], l_f, odds_only))
|
|
|
+
|
|
|
+
|
|
|
+def two_intodb(data1, data2, data3, cursor, redis_db):
|
|
|
+ if data1:
|
|
|
+ for key, value in data1.items():
|
|
|
+ if value:
|
|
|
+ new_hash = hash_func(match_id=data2['game_id'], odds_code=data3 + key, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+
|
|
|
+ r_hash = r_func(match_id=data2['game_id'], odds_code=data3 + key, sort=data2['sort'], p_id=data2['p_id'],odd=value)
|
|
|
+ odds_only = r_hash
|
|
|
+ if redis_db.hexists("hg3535_lanqiu", r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset("hg3535_lanqiu", r_hash, 0)
|
|
|
+ sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+ cursor.execute(sql1, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+ key, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'], odds_only,key))
|
|
|
+ # 更新主队st_zq_odds_record表
|
|
|
+ sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s);"
|
|
|
+ cursor.execute(sql2, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], key, odds_only))
|
|
|
+
|
|
|
+
|
|
|
+def three_intodb(data1, data2, cursor, redis_db):
|
|
|
+ if data1:
|
|
|
+ for key, value in data1.items():
|
|
|
+ if value:
|
|
|
+ new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+
|
|
|
+ r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'],odd=value)
|
|
|
+ odds_only = r_hash
|
|
|
+ if redis_db.hexists("hg3535_lanqiu", r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset("hg3535_lanqiu", r_hash, 0)
|
|
|
+ sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s;"
|
|
|
+ cursor.execute(sql1, (
|
|
|
+ int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash, data2['expire_time'],
|
|
|
+ odds_only,data2['utime'], value, data2['expire_time'], odds_only))
|
|
|
+ # 更新主队st_zq_odds_record表
|
|
|
+ sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+ cursor.execute(sql2, (
|
|
|
+ int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], odds_only))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+# 插入篮球赛事表
|
|
|
+def into_competition(data, cursor):
|
|
|
+ Competition_sql = "insert into st_lq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag, type, source,expire_time,is_today,is_morningplate,is_stringscene) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s,%s, %s, %s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s,is_morningplate=%s,is_stringscene=%s;"
|
|
|
+ cursor.execute(Competition_sql, (
|
|
|
+ data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
|
|
|
+ data['match_time'],
|
|
|
+ data['utime'], data['utime'], data['number'], data['pt'], data["source"], data['expire_time'], data['is_today'],
|
|
|
+ data['is_morningplate'], data['is_stringscene'], data['number'], data['expire_time'], data['is_today'],
|
|
|
+ data['is_morningplate'], data['is_stringscene']))
|
|
|
+
|
|
|
+
|
|
|
+# 插入足球赛事表----------------------------------------------------------------------------------------------------------
|
|
|
+def zqone_competition(data, cursor):
|
|
|
+ Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_today,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s,us_time=%s;"
|
|
|
+ cursor.execute(Competition_sql, (
|
|
|
+ data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
|
|
|
+ data['match_time'],
|
|
|
+ data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_today'],
|
|
|
+ data['us_time'], data['number'], data['expire_time'], data['is_today'],data['us_time']))
|
|
|
+
|
|
|
+
|
|
|
+def zqtwo_competition(data, cursor):
|
|
|
+ Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_morningplate,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_morningplate=%s,us_time=%s;"
|
|
|
+ cursor.execute(Competition_sql, (
|
|
|
+ data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
|
|
|
+ data['match_time'],
|
|
|
+ data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_morningplate'],
|
|
|
+ data['us_time'], data['number'], data['expire_time'], data['is_morningplate'], data['us_time']))
|
|
|
+
|
|
|
+
|
|
|
+def zqthree_competition(data, cursor):
|
|
|
+ Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_stringscene,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_stringscene=%s,us_time=%s;"
|
|
|
+ cursor.execute(Competition_sql, (
|
|
|
+ data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
|
|
|
+ data['match_time'],
|
|
|
+ data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_stringscene'],
|
|
|
+ data['us_time'], data['number'], data['expire_time'], data['is_stringscene'], data['us_time']))
|
|
|
+
|
|
|
+
|
|
|
+# 足球 插入赔率 让球 大小-------------------------------------------------------------------------------------------------
|
|
|
+def zqone_intodb(data1, data2, data3, data4, cursor, redis_db):
|
|
|
+ if data1:
|
|
|
+ for index, value in enumerate(data1):
|
|
|
+ if value:
|
|
|
+ new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'])
|
|
|
+ r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'], odd=value)
|
|
|
+ odds_only = r_hash
|
|
|
+ f1 = fuhao(str(data4[index]))
|
|
|
+ if redis_db.hexists("hg3535_zuqiu", r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset("hg3535_zuqiu", r_hash, 0)
|
|
|
+ sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+ cursor.execute(sql1, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+ data2['p_id'], data2["p_code"], index, data2["source"], new_hash,
|
|
|
+ f1, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'],
|
|
|
+ odds_only, f1))
|
|
|
+
|
|
|
+ # 更新主队st_zq_odds_record表
|
|
|
+ sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+ cursor.execute(sql2, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+ data2['p_id'], data2["p_code"], index, data2["source"], f1, odds_only))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+# 足球 插入赔率 独赢 单双
|
|
|
+def zqtwo_intodb(data1, data2, data3, data4, cursor, redis_db):
|
|
|
+ if data1:
|
|
|
+ new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+ r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'],
|
|
|
+ odd=data1)
|
|
|
+ odds_only = r_hash
|
|
|
+ if redis_db.hexists("hg3535_zuqiu", r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset("hg3535_zuqiu", r_hash, 0)
|
|
|
+ sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time, odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+ cursor.execute(sql1, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+ data4, data2['expire_time'], odds_only, data2['utime'], data1, data2['expire_time'], odds_only,data4))
|
|
|
+ # 更新主队st_zq_odds_record表
|
|
|
+ sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s,%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+ cursor.execute(sql2, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], data4, odds_only))
|
|
|
+
|
|
|
+
|
|
|
+def gjz_into(data, cursor, r_hash, s_hash, redis_db):
|
|
|
+ if redis_db.hexists('hg3535_guanjun', r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset('hg3535_guanjun', r_hash, 0)
|
|
|
+ # if pt == 1:
|
|
|
+ sql = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
|
|
|
+ cursor.execute(sql, (
|
|
|
+ int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+ data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+ data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
|
|
|
+ data['champion_team'], data['expire_time'], data['odds_only']))
|
|
|
+ # 插入st_zq_odds_record表
|
|
|
+ new_sql = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
|
|
|
+ cursor.execute(new_sql, (
|
|
|
+ int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+ data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+ data['tema_home'], 1, "hg3535", data['odds_only']))
|
|
|
+
|
|
|
+ if redis_db.hexists('hg3535_liansai', s_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset('hg3535_liansai', s_hash, 0)
|
|
|
+ league_sql = "insert into st_zq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
|
|
|
+ cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
|
|
|
+
|
|
|
+
|
|
|
+def gjl_into(data, cursor, r_hash, s_hash, redis_db):
|
|
|
+ if redis_db.hexists('hg3535_guanjun', r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset('hg3535_guanjun', r_hash, 0)
|
|
|
+ sql = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
|
|
|
+ cursor.execute(sql, (
|
|
|
+ int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+ data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+ data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
|
|
|
+ data['champion_team'], data['expire_time'], data['odds_only']))
|
|
|
+ # 插入st_zq_odds_record表
|
|
|
+ new_sql = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
|
|
|
+ cursor.execute(new_sql, (
|
|
|
+ int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+ data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+ data['tema_home'], 1, "hg3535", data['odds_only']))
|
|
|
+ # 插入st_zq_league表
|
|
|
+ if redis_db.hexists('hg3535_liansai', s_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset('hg3535_liansai', s_hash, 0)
|
|
|
+ league_sql = "insert into st_lq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
|
|
|
+ cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
|
|
|
+
|
|
|
+
|
|
|
+def gjw_into(data, cursor, r_hash, s_hash, redis_db):
|
|
|
+ if redis_db.hexists('hg3535_guanjun', r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset('hg3535_guanjun', r_hash, 0)
|
|
|
+ sql = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
|
|
|
+ cursor.execute(sql, (
|
|
|
+ int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+ data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+ data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
|
|
|
+ data['champion_team'], data['expire_time'], data['odds_only']))
|
|
|
+ # 插入st_zq_odds_record表
|
|
|
+ new_sql = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s,%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s)"
|
|
|
+ cursor.execute(new_sql, (
|
|
|
+ int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+ data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+ data['tema_home'], 1, "hg3535", data['odds_only']))
|
|
|
+ # 插入st_zq_league表
|
|
|
+ if redis_db.hexists('hg3535_liansai', s_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset('hg3535_liansai', s_hash, 0)
|
|
|
+ league_sql = "insert into st_wq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
|
|
|
+ cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
|
|
|
+
|
|
|
+
|
|
|
+def gjb_into(data, cursor, r_hash, s_hash, redis_db):
|
|
|
+ if redis_db.hexists('hg3535_guanjun', r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset('hg3535_guanjun', r_hash, 0)
|
|
|
+ sql = "insert into st_bq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
|
|
|
+ cursor.execute(sql, (
|
|
|
+ int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+ data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+ data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
|
|
|
+ data['champion_team'], data['expire_time'], data['odds_only']))
|
|
|
+ # 插入st_zq_odds_record表
|
|
|
+ new_sql = "insert into st_bq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
|
|
|
+ cursor.execute(new_sql, (
|
|
|
+ int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+ data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+ data['tema_home'], 1, "hg3535", data['odds_only']))
|
|
|
+ # 插入st_zq_league表
|
|
|
+ if redis_db.hexists('hg3535_liansai', s_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset('hg3535_liansai', s_hash, 0)
|
|
|
+ league_sql = "insert into st_bq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
|
|
|
+ cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
|
|
|
+
|
|
|
+
|
|
|
+# 网球 插入赔率----------------------------------------------------------------------------------------------------------
|
|
|
+def wqone_intodb(data1, data2, data3, cursor, redis_db):
|
|
|
+ if data1:
|
|
|
+ for key, value in data1.items():
|
|
|
+ if value:
|
|
|
+ new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+ r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'], odd=value)
|
|
|
+ odds_only = r_hash
|
|
|
+ w_f = fuhao(str(data3[key]))
|
|
|
+ if redis_db.hexists("hg3535_wangqiu", r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset("hg3535_wangqiu", r_hash, 0)
|
|
|
+ sql1 = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+ cursor.execute(sql1, (
|
|
|
+ int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+ w_f, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'],
|
|
|
+ odds_only, w_f))
|
|
|
+ # 更新主队st_zq_odds_record表
|
|
|
+ sql2 = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+ cursor.execute(sql2, (
|
|
|
+ int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], w_f, odds_only))
|
|
|
+
|
|
|
+
|
|
|
+# 棒球 插入赔率----------------------------------------------------------------------------------------------------------
|
|
|
+def bqone_intodb(data1, data2, data3, cursor, redis_db):
|
|
|
+ if data1:
|
|
|
+ for key, value in data1.items():
|
|
|
+ if value:
|
|
|
+ new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+ r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'], odd=value)
|
|
|
+ odds_only = r_hash
|
|
|
+ b_f = fuhao(str(data3[key]))
|
|
|
+ if redis_db.hexists("hg3535_bangqiu", r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset("hg3535_bangqiu", r_hash, 0)
|
|
|
+ sql1 = "insert into st_bq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s"
|
|
|
+ cursor.execute(sql1, (
|
|
|
+ int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+ b_f, data2['expire_time'], odds_only, data2['utime'], value,data2['expire_time'],
|
|
|
+ odds_only, b_f))
|
|
|
+ # 更新主队st_zq_odds_record表
|
|
|
+ sql2 = "insert into st_bq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s, %s);"
|
|
|
+ cursor.execute(sql2, (
|
|
|
+ int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], b_f, odds_only))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+def get_pcode(corner_ball, code):
|
|
|
+ code_dict = {'concede_size': 1, 'capot': 2, 'two_sides': 3, 'total_goal': 4, 'half_full': 5, 'bodan': 6,
|
|
|
+ 'first_last_ball': 7, 'temaball': 11}
|
|
|
+ if corner_ball == "角球":
|
|
|
+ p_code = "corner_ball"
|
|
|
+ p_id = 9
|
|
|
+ elif corner_ball == "会晋级":
|
|
|
+ p_code = "promotion"
|
|
|
+ p_id = 10
|
|
|
+ elif corner_ball == "罚牌数":
|
|
|
+ p_code = "Penalty_card"
|
|
|
+ p_id = 12
|
|
|
+ else:
|
|
|
+ p_code = code
|
|
|
+ p_id = code_dict[code]
|
|
|
+ return p_code, p_id
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+# ------------------------------------------------------------------------------------------------------------------------
|
|
|
+def new_times(ctime):
|
|
|
+ time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
|
|
|
+ time2 = time.localtime(time1)
|
|
|
+ time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
|
|
|
+ data_time = str(time3).split(" ")
|
|
|
+ match_date = data_time[0]
|
|
|
+ match_time = data_time[1]
|
|
|
+ return match_date,match_time
|
|
|
+
|
|
|
+
|
|
|
+def zqone_intodbs(data1, data2, data3, data4, cursor, redis_db):
|
|
|
+ if data1:
|
|
|
+ for index, value in enumerate(data1):
|
|
|
+ if value:
|
|
|
+ new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'])
|
|
|
+ r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'], odd=value)
|
|
|
+ odds_only = r_hash
|
|
|
+ if redis_db.hexists("hg3535_zuqiu", r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset("hg3535_zuqiu", r_hash, 0)
|
|
|
+ # if data2['pt'] == 0:
|
|
|
+ sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only,is_rollball) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+ cursor.execute(sql1, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+ data2['p_id'], data2["p_code"], index, data2["source"], new_hash,
|
|
|
+ data4[index], data2['expire_time'], odds_only, 1, data2['utime'], value, data2['expire_time'],
|
|
|
+ odds_only,data4[index]))
|
|
|
+
|
|
|
+ # 更新主队st_zq_odds_record表
|
|
|
+ sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only,is_rollball) values (%s,%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+ cursor.execute(sql2, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+ data2['p_id'], data2["p_code"], index, data2["source"], data4[index], odds_only,1))
|
|
|
+ #写入数据设置默认值竟然不生效 待看
|
|
|
+ sql3 = "insert into st_zq_result(match_id, match_score, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_winer, update_time, match_time,match_process,tag,lg_id,u_home_score,u_guest_score,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set update_time=%s,match_score=%s,match_time=%s,match_process=%s,home_score=%s,guest_score=%s;"
|
|
|
+ cursor.execute(sql3, (
|
|
|
+ int(data2['game_id']), data2['match_score'],data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','','',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['league_id']),0,0,'hg3535',data2["p_code"],data2['utime'],data2['match_score'],data2['time_game'],data2['half_way'],data2['score_home'],data2['score_guest']
|
|
|
+ ))
|
|
|
+
|
|
|
+ sql4 = "insert into st_zq_result_record(lg_id, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_score, match_winer, update_time, match_time,match_process,tag,match_id,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s);"
|
|
|
+ cursor.execute(sql4, (
|
|
|
+ int(data2['league_id']), data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','',data2['match_score'],'',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['game_id']),'hg3535',data2["p_code"]
|
|
|
+ ))
|
|
|
+
|
|
|
+
|
|
|
+def zqtwo_intodbs(data1, data2, data3, data4, cursor, redis_db):
|
|
|
+ if data1:
|
|
|
+ new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+ r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'],
|
|
|
+ odd=data1)
|
|
|
+ odds_only = r_hash
|
|
|
+ if redis_db.hexists("hg3535_zuqiu", r_hash):
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ redis_db.hset("hg3535_zuqiu", r_hash, 0)
|
|
|
+ # if data2['pt'] == 1:
|
|
|
+ sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time, odds_only,is_today) values (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+ cursor.execute(sql1, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+ data4, data2['expire_time'], odds_only, 1, data2['utime'], data1, data2['expire_time'], odds_only,data4))
|
|
|
+ # 更新主队st_zq_odds_record表
|
|
|
+ sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only, is_today) values (%s,%s,%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+ cursor.execute(sql2, (
|
|
|
+ int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
|
|
|
+ data2['p_id'], data2["p_code"], data2['sort'], data2["source"], data4, odds_only, 1))
|
|
|
+
|
|
|
+ sql3 = "insert into st_zq_result(match_id, match_score, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_winer, update_time, match_time,match_process,tag,lg_id,u_home_score,u_guest_score,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set update_time=%s,match_score=%s,match_time=%s,match_process=%s,home_score=%s,guest_score=%s;"
|
|
|
+ cursor.execute(sql3, (
|
|
|
+ int(data2['game_id']), data2['match_score'],data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','','',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['league_id']),0,0,'hg3535',data2["p_code"],data2['utime'],data2['match_score'],data2['time_game'],data2['half_way'],data2['score_home'],data2['score_guest']
|
|
|
+ ))
|
|
|
+
|
|
|
+ sql4 = "insert into st_zq_result_record(lg_id, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_score, match_winer, update_time, match_time,match_process,tag,match_id,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s);"
|
|
|
+ cursor.execute(sql4, (
|
|
|
+ int(data2['league_id']), data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','',data2['match_score'],'',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['game_id']),'hg3535',data2["p_code"]
|
|
|
+ ))
|
|
|
+
|
|
|
+
|
|
|
+def zqone_competitions(data, cursor):
|
|
|
+ Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, status, match_id, match_date, match_time, ctime, utime,tag, source,type,expire_time,us_time,is_rollball) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set utime = %s,status=%s,tag=%s,expire_time=%s;"
|
|
|
+ cursor.execute(Competition_sql, (
|
|
|
+ data['team_home'], data['team_guest'], data['league_id'],1,data['game_id'], data['match_date'],
|
|
|
+ data['match_time'],
|
|
|
+ data['utime'], data['utime'], data['number'], data["source"], 4,data['expire_time'], data['us_time'],data['is_rollball'],
|
|
|
+ data['utime'], 1, data['number'], data['expire_time']))
|
|
|
+
|
|
|
+
|
|
|
+def get_pcodes(corner_ball, code):
|
|
|
+ code_dict = {'concede_size': 1, 'capot': 2, 'two_sides': 3, 'total_goal': 4, 'half_full': 5, 'bodan': 6,
|
|
|
+ 'first_last_ball': 7, 'temaball': 11}
|
|
|
+ if corner_ball == "角球":
|
|
|
+ p_code = "corner_ball"
|
|
|
+ p_id = 9
|
|
|
+ elif corner_ball == "会晋级":
|
|
|
+ p_code = "promotion"
|
|
|
+ p_id = 10
|
|
|
+ elif corner_ball == "罚牌数":
|
|
|
+ p_code = "Penalty_card"
|
|
|
+ p_id = 12
|
|
|
+ else:
|
|
|
+ p_code = code
|
|
|
+ p_id = code_dict[code]
|
|
|
+ return p_code, p_id
|
|
|
+
|
|
|
+
|
|
|
+def news_times(ctime):
|
|
|
+ time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
|
|
|
+ time2 = time.localtime(time1)
|
|
|
+ time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
|
|
|
+ time4 = time3
|
|
|
+ data_time = str(time4).split(" ")
|
|
|
+ match_date = data_time[0]
|
|
|
+ match_time = data_time[1]
|
|
|
+ return match_date, match_time, time3
|
|
|
+
|
|
|
+
|
|
|
+# def hash_func(match_id, odds_code, sort, p_id):
|
|
|
+# m = hashlib.md5()
|
|
|
+# a = str(match_id) + str(odds_code) + str(sort) + str(p_id)
|
|
|
+# m.update(a.encode('utf-8'))
|
|
|
+# c = m.hexdigest()
|
|
|
+# return c
|
|
|
+#
|
|
|
+#
|
|
|
+# # 生成odds_only哈希
|
|
|
+# def r_func(match_id, odds_code, sort, p_id, odd):
|
|
|
+# m = hashlib.md5()
|
|
|
+# a = str(match_id) + str(odds_code) + str(sort) + str(p_id) + str(odd)
|
|
|
+# m.update(a.encode('utf-8'))
|
|
|
+# c = m.hexdigest()
|
|
|
+# return c
|
|
|
+#
|
|
|
+#
|
|
|
+# # 转换成本地时间
|
|
|
+# def new_time(ctime):
|
|
|
+# time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
|
|
|
+# time2 = time.localtime(time1)
|
|
|
+# time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
|
|
|
+# time4 = time3
|
|
|
+# data_time = str(time4).split(" ")
|
|
|
+# match_date = data_time[0]
|
|
|
+# match_time = data_time[1]
|
|
|
+# return match_date, match_time, time3
|
|
|
+#
|
|
|
+#
|
|
|
+# def out_time(ctime, i):
|
|
|
+# ctime1 = datetime.datetime.strptime(ctime, "%Y-%m-%d %H:%M:%S")
|
|
|
+# n_ctime = (ctime1 + datetime.timedelta(hours=i)).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
+# return n_ctime
|
|
|
+#
|
|
|
+#
|
|
|
+# def fuhao(f):
|
|
|
+# if f.startswith('+'):
|
|
|
+# f = f.replace('+', '-')
|
|
|
+# return f
|
|
|
+# elif f.startswith('-'):
|
|
|
+# f = f.replace('-', '+')
|
|
|
+# return f
|
|
|
+# else:
|
|
|
+# return f
|
|
|
+#
|
|
|
+#
|
|
|
+# # 篮球插入赔率 -----------------------------------------------------------------------------------------------------------
|
|
|
+# def one_intodb(data1, data2, data3, cursor, redis_db):
|
|
|
+# if data1:
|
|
|
+# for key, value in data1.items():
|
|
|
+# if value:
|
|
|
+# for x, y in enumerate(value):
|
|
|
+# new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=x, p_id=data2['p_id'])
|
|
|
+# r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=x, p_id=data2['p_id'],odd=y)
|
|
|
+# odds_only = r_hash
|
|
|
+# l_f = fuhao(str(data3[key][x]))
|
|
|
+# if redis_db.hexists("hg3535_lanqiu", r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset("hg3535_lanqiu", r_hash, 0)
|
|
|
+# sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+# cursor.execute(sql1, (
|
|
|
+# int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], y,
|
|
|
+# data2['p_id'], data2["p_code"], x, data2["source"], new_hash,
|
|
|
+# l_f, data2['expire_time'], odds_only,data2['utime'], y, data2['expire_time'],
|
|
|
+# odds_only, l_f))
|
|
|
+# # 更新主队st_zq_odds_record表
|
|
|
+# sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s);"
|
|
|
+# cursor.execute(sql2, (
|
|
|
+# int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], y,
|
|
|
+# data2['p_id'], data2["p_code"], x, data2["source"], l_f, odds_only))
|
|
|
+#
|
|
|
+#
|
|
|
+# def two_intodb(data1, data2, data3, cursor, redis_db):
|
|
|
+# if data1:
|
|
|
+# for key, value in data1.items():
|
|
|
+# if value:
|
|
|
+# new_hash = hash_func(match_id=data2['game_id'], odds_code=data3 + key, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+#
|
|
|
+# r_hash = r_func(match_id=data2['game_id'], odds_code=data3 + key, sort=data2['sort'], p_id=data2['p_id'],odd=value)
|
|
|
+# odds_only = r_hash
|
|
|
+# if redis_db.hexists("hg3535_lanqiu", r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset("hg3535_lanqiu", r_hash, 0)
|
|
|
+# sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+# cursor.execute(sql1, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+# key, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'], odds_only,key))
|
|
|
+# # 更新主队st_zq_odds_record表
|
|
|
+# sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s);"
|
|
|
+# cursor.execute(sql2, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], key, odds_only))
|
|
|
+#
|
|
|
+#
|
|
|
+# def three_intodb(data1, data2, cursor, redis_db):
|
|
|
+# if data1:
|
|
|
+# for key, value in data1.items():
|
|
|
+# if value:
|
|
|
+# new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+#
|
|
|
+# r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'],odd=value)
|
|
|
+# odds_only = r_hash
|
|
|
+# if redis_db.hexists("hg3535_lanqiu", r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset("hg3535_lanqiu", r_hash, 0)
|
|
|
+# sql1 = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s;"
|
|
|
+# cursor.execute(sql1, (
|
|
|
+# int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash, data2['expire_time'],
|
|
|
+# odds_only,data2['utime'], value, data2['expire_time'], odds_only))
|
|
|
+# # 更新主队st_zq_odds_record表
|
|
|
+# sql2 = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+# cursor.execute(sql2, (
|
|
|
+# int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], odds_only))
|
|
|
+#
|
|
|
+#
|
|
|
+# # 插入篮球赛事表
|
|
|
+# def into_competition(data, cursor):
|
|
|
+# Competition_sql = "insert into st_lq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag, type, source,expire_time,is_today,is_morningplate,is_stringscene) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s,%s, %s, %s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s,is_morningplate=%s,is_stringscene=%s;"
|
|
|
+# cursor.execute(Competition_sql, (
|
|
|
+# data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
|
|
|
+# data['match_time'],
|
|
|
+# data['utime'], data['utime'], data['number'], data['pt'], data["source"], data['expire_time'], data['is_today'],
|
|
|
+# data['is_morningplate'], data['is_stringscene'], data['number'], data['expire_time'], data['is_today'],
|
|
|
+# data['is_morningplate'], data['is_stringscene']))
|
|
|
+#
|
|
|
+#
|
|
|
+# # 插入足球赛事表----------------------------------------------------------------------------------------------------------
|
|
|
+# def zqone_competition(data, cursor):
|
|
|
+# Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_today,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s,us_time=%s;"
|
|
|
+# cursor.execute(Competition_sql, (
|
|
|
+# data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
|
|
|
+# data['match_time'],
|
|
|
+# data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_today'],
|
|
|
+# data['us_time'], data['number'], data['expire_time'], data['is_today'],data['us_time']))
|
|
|
+#
|
|
|
+#
|
|
|
+# def zqtwo_competition(data, cursor):
|
|
|
+# Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_morningplate,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_morningplate=%s,us_time=%s;"
|
|
|
+# cursor.execute(Competition_sql, (
|
|
|
+# data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
|
|
|
+# data['match_time'],
|
|
|
+# data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_morningplate'],
|
|
|
+# data['us_time'], data['number'], data['expire_time'], data['is_morningplate'], data['us_time']))
|
|
|
+#
|
|
|
+#
|
|
|
+# def zqthree_competition(data, cursor):
|
|
|
+# Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time, ctime, utime, tag,source, expire_time,is_stringscene,us_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s,%s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_stringscene=%s,us_time=%s;"
|
|
|
+# cursor.execute(Competition_sql, (
|
|
|
+# data['team_home'], data['team_guest'], data['league_id'], data['game_id'], data['match_date'],
|
|
|
+# data['match_time'],
|
|
|
+# data['utime'], data['utime'], data['number'], data["source"], data['expire_time'], data['is_stringscene'],
|
|
|
+# data['us_time'], data['number'], data['expire_time'], data['is_stringscene'], data['us_time']))
|
|
|
+#
|
|
|
+#
|
|
|
+# # 足球 插入赔率 让球 大小-------------------------------------------------------------------------------------------------
|
|
|
+# def zqone_intodb(data1, data2, data3, data4, cursor, redis_db):
|
|
|
+# if data1:
|
|
|
+# for index, value in enumerate(data1):
|
|
|
+# if value:
|
|
|
+# new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'])
|
|
|
+# r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'], odd=value)
|
|
|
+# odds_only = r_hash
|
|
|
+# f1 = fuhao(str(data4[index]))
|
|
|
+# if redis_db.hexists("hg3535_zuqiu", r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset("hg3535_zuqiu", r_hash, 0)
|
|
|
+# sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+# cursor.execute(sql1, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+# data2['p_id'], data2["p_code"], index, data2["source"], new_hash,
|
|
|
+# f1, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'],
|
|
|
+# odds_only, f1))
|
|
|
+#
|
|
|
+# # 更新主队st_zq_odds_record表
|
|
|
+# sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+# cursor.execute(sql2, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+# data2['p_id'], data2["p_code"], index, data2["source"], f1, odds_only))
|
|
|
+#
|
|
|
+#
|
|
|
+#
|
|
|
+# # 足球 插入赔率 独赢 单双
|
|
|
+# def zqtwo_intodb(data1, data2, data3, data4, cursor, redis_db):
|
|
|
+# if data1:
|
|
|
+# new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+# r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'],
|
|
|
+# odd=data1)
|
|
|
+# odds_only = r_hash
|
|
|
+# if redis_db.hexists("hg3535_zuqiu", r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset("hg3535_zuqiu", r_hash, 0)
|
|
|
+# sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time, odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+# cursor.execute(sql1, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+# data4, data2['expire_time'], odds_only, data2['utime'], data1, data2['expire_time'], odds_only,data4))
|
|
|
+# # 更新主队st_zq_odds_record表
|
|
|
+# sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s,%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+# cursor.execute(sql2, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], data4, odds_only))
|
|
|
+#
|
|
|
+#
|
|
|
+# def gjz_into(data, cursor, r_hash, s_hash, redis_db):
|
|
|
+# if redis_db.hexists('hg3535_guanjun', r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset('hg3535_guanjun', r_hash, 0)
|
|
|
+# # if pt == 1:
|
|
|
+# sql = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
|
|
|
+# cursor.execute(sql, (
|
|
|
+# int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+# data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+# data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
|
|
|
+# data['champion_team'], data['expire_time'], data['odds_only']))
|
|
|
+# # 插入st_zq_odds_record表
|
|
|
+# new_sql = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
|
|
|
+# cursor.execute(new_sql, (
|
|
|
+# int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+# data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+# data['tema_home'], 1, "hg3535", data['odds_only']))
|
|
|
+#
|
|
|
+# if redis_db.hexists('hg3535_liansai', s_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset('hg3535_liansai', s_hash, 0)
|
|
|
+# league_sql = "insert into st_zq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
|
|
|
+# cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
|
|
|
+#
|
|
|
+#
|
|
|
+# def gjl_into(data, cursor, r_hash, s_hash, redis_db):
|
|
|
+# if redis_db.hexists('hg3535_guanjun', r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset('hg3535_guanjun', r_hash, 0)
|
|
|
+# sql = "insert into st_lq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
|
|
|
+# cursor.execute(sql, (
|
|
|
+# int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+# data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+# data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
|
|
|
+# data['champion_team'], data['expire_time'], data['odds_only']))
|
|
|
+# # 插入st_zq_odds_record表
|
|
|
+# new_sql = "insert into st_lq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
|
|
|
+# cursor.execute(new_sql, (
|
|
|
+# int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+# data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+# data['tema_home'], 1, "hg3535", data['odds_only']))
|
|
|
+# # 插入st_zq_league表
|
|
|
+# if redis_db.hexists('hg3535_liansai', s_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset('hg3535_liansai', s_hash, 0)
|
|
|
+# league_sql = "insert into st_lq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
|
|
|
+# cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
|
|
|
+#
|
|
|
+#
|
|
|
+# def gjw_into(data, cursor, r_hash, s_hash, redis_db):
|
|
|
+# if redis_db.hexists('hg3535_guanjun', r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset('hg3535_guanjun', r_hash, 0)
|
|
|
+# sql = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
|
|
|
+# cursor.execute(sql, (
|
|
|
+# int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+# data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+# data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
|
|
|
+# data['champion_team'], data['expire_time'], data['odds_only']))
|
|
|
+# # 插入st_zq_odds_record表
|
|
|
+# new_sql = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s,%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s)"
|
|
|
+# cursor.execute(new_sql, (
|
|
|
+# int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+# data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+# data['tema_home'], 1, "hg3535", data['odds_only']))
|
|
|
+# # 插入st_zq_league表
|
|
|
+# if redis_db.hexists('hg3535_liansai', s_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset('hg3535_liansai', s_hash, 0)
|
|
|
+# league_sql = "insert into st_wq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
|
|
|
+# cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
|
|
|
+#
|
|
|
+#
|
|
|
+# def gjb_into(data, cursor, r_hash, s_hash, redis_db):
|
|
|
+# if redis_db.hexists('hg3535_guanjun', r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset('hg3535_guanjun', r_hash, 0)
|
|
|
+# sql = "insert into st_bq_odds(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, team, type, source, sole, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s,%s, %s, %s, %s) on conflict(sole) do update set utime = %s,odds = %s,expire_time=%s,odds_only=%s;"
|
|
|
+# cursor.execute(sql, (
|
|
|
+# int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+# data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+# data['tema_home'], 1, "hg3535", data['new_hash'], data['expire_time'], data['odds_only'],data['utime'],
|
|
|
+# data['champion_team'], data['expire_time'], data['odds_only']))
|
|
|
+# # 插入st_zq_odds_record表
|
|
|
+# new_sql = "insert into st_bq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, team, type, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s)"
|
|
|
+# cursor.execute(new_sql, (
|
|
|
+# int(data['league_id']), data['new_champion'], int(data['game_id']), data['utime'], data['utime'],
|
|
|
+# data['champion_team'], data['p_id'], data['new_league_name'],
|
|
|
+# data['tema_home'], 1, "hg3535", data['odds_only']))
|
|
|
+# # 插入st_zq_league表
|
|
|
+# if redis_db.hexists('hg3535_liansai', s_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset('hg3535_liansai', s_hash, 0)
|
|
|
+# league_sql = "insert into st_bq_league(name_chinese, lg_id,last_time) values (%s, %s, %s) on conflict(lg_id) do update set last_time = %s,source=%s;"
|
|
|
+# cursor.execute(league_sql, (data['league_name'], data['league_id'], data['time3'], data['time3'], "hg3535"))
|
|
|
+#
|
|
|
+#
|
|
|
+# # 网球 插入赔率----------------------------------------------------------------------------------------------------------
|
|
|
+# def wqone_intodb(data1, data2, data3, cursor, redis_db):
|
|
|
+# if data1:
|
|
|
+# for key, value in data1.items():
|
|
|
+# if value:
|
|
|
+# new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+# r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'], odd=value)
|
|
|
+# odds_only = r_hash
|
|
|
+# w_f = fuhao(str(data3[key]))
|
|
|
+# if redis_db.hexists("hg3535_wangqiu", r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset("hg3535_wangqiu", r_hash, 0)
|
|
|
+# sql1 = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+# cursor.execute(sql1, (
|
|
|
+# int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+# w_f, data2['expire_time'], odds_only,data2['utime'], value, data2['expire_time'],
|
|
|
+# odds_only, w_f))
|
|
|
+# # 更新主队st_zq_odds_record表
|
|
|
+# sql2 = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+# cursor.execute(sql2, (
|
|
|
+# int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], w_f, odds_only))
|
|
|
+#
|
|
|
+#
|
|
|
+# # 棒球 插入赔率----------------------------------------------------------------------------------------------------------
|
|
|
+# def bqone_intodb(data1, data2, data3, cursor, redis_db):
|
|
|
+# if data1:
|
|
|
+# for key, value in data1.items():
|
|
|
+# if value:
|
|
|
+# new_hash = hash_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+# r_hash = r_func(match_id=data2['game_id'], odds_code=key, sort=data2['sort'], p_id=data2['p_id'], odd=value)
|
|
|
+# odds_only = r_hash
|
|
|
+# b_f = fuhao(str(data3[key]))
|
|
|
+# if redis_db.hexists("hg3535_bangqiu", r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset("hg3535_bangqiu", r_hash, 0)
|
|
|
+# sql1 = "insert into st_bq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s"
|
|
|
+# cursor.execute(sql1, (
|
|
|
+# int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+# b_f, data2['expire_time'], odds_only, data2['utime'], value,data2['expire_time'],
|
|
|
+# odds_only, b_f))
|
|
|
+# # 更新主队st_zq_odds_record表
|
|
|
+# sql2 = "insert into st_bq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s, %s);"
|
|
|
+# cursor.execute(sql2, (
|
|
|
+# int(data2['league_id']), key, int(data2['game_id']), data2['utime'], data2['utime'], value,
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], b_f, odds_only))
|
|
|
+#
|
|
|
+#
|
|
|
+#
|
|
|
+# def get_pcode(corner_ball, code):
|
|
|
+# code_dict = {'concede_size': 1, 'capot': 2, 'two_sides': 3, 'total_goal': 4, 'half_full': 5, 'bodan': 6,
|
|
|
+# 'first_last_ball': 7, 'temaball': 11}
|
|
|
+# if corner_ball == "角球":
|
|
|
+# p_code = "corner_ball"
|
|
|
+# p_id = 9
|
|
|
+# elif corner_ball == "会晋级":
|
|
|
+# p_code = "promotion"
|
|
|
+# p_id = 10
|
|
|
+# elif corner_ball == "罚牌数":
|
|
|
+# p_code = "Penalty_card"
|
|
|
+# p_id = 12
|
|
|
+# else:
|
|
|
+# p_code = code
|
|
|
+# p_id = code_dict[code]
|
|
|
+# return p_code, p_id
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#滚球方法都加了s
|
|
|
+
|
|
|
+# def zqone_intodbs(data1, data2, data3, data4, cursor, redis_db):
|
|
|
+# if data1:
|
|
|
+# for index, value in enumerate(data1):
|
|
|
+# if value:
|
|
|
+# new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'])
|
|
|
+# r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=index, p_id=data2['p_id'], odd=value)
|
|
|
+# odds_only = r_hash
|
|
|
+# if redis_db.hexists("hg3535_zuqiu", r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset("hg3535_zuqiu", r_hash, 0)
|
|
|
+# # if data2['pt'] == 0:
|
|
|
+# sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only,is_rollball) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+# cursor.execute(sql1, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+# data2['p_id'], data2["p_code"], index, data2["source"], new_hash,
|
|
|
+# data4[index], data2['expire_time'], odds_only, 1, data2['utime'], value, data2['expire_time'],
|
|
|
+# odds_only,data4[index]))
|
|
|
+#
|
|
|
+# # 更新主队st_zq_odds_record表
|
|
|
+# sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only,is_rollball) values (%s,%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+# cursor.execute(sql2, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], float(value),
|
|
|
+# data2['p_id'], data2["p_code"], index, data2["source"], data4[index], odds_only,1))
|
|
|
+# #写入数据设置默认值竟然不生效 待看
|
|
|
+# sql3 = "insert into st_zq_result(match_id, match_score, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_winer, update_time, match_time,match_process,tag,lg_id,u_home_score,u_guest_score,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set update_time=%s,match_score=%s,match_time=%s,match_process=%s,home_score=%s,guest_score=%s;"
|
|
|
+# cursor.execute(sql3, (
|
|
|
+# int(data2['game_id']), data2['match_score'],data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','','',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['league_id']),0,0,'hg3535',data2["p_code"],data2['utime'],data2['match_score'],data2['time_game'],data2['half_way'],data2['score_home'],data2['score_guest']
|
|
|
+# ))
|
|
|
+#
|
|
|
+# sql4 = "insert into st_zq_result_record(lg_id, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_score, match_winer, update_time, match_time,match_process,tag,match_id,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s);"
|
|
|
+# cursor.execute(sql4, (
|
|
|
+# int(data2['league_id']), data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','',data2['match_score'],'',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['game_id']),'hg3535',data2["p_code"]
|
|
|
+# ))
|
|
|
+#
|
|
|
+# def zqtwo_intodbs(data1, data2, data3, data4, cursor, redis_db):
|
|
|
+# if data1:
|
|
|
+# new_hash = hash_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'])
|
|
|
+# r_hash = r_func(match_id=data2['game_id'], odds_code=data3, sort=data2['sort'], p_id=data2['p_id'],
|
|
|
+# odd=data1)
|
|
|
+# odds_only = r_hash
|
|
|
+# if redis_db.hexists("hg3535_zuqiu", r_hash):
|
|
|
+# pass
|
|
|
+# else:
|
|
|
+# redis_db.hset("hg3535_zuqiu", r_hash, 0)
|
|
|
+# # if data2['pt'] == 1:
|
|
|
+# sql1 = "insert into st_zq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time, odds_only,is_today) values (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s,condition=%s;"
|
|
|
+# cursor.execute(sql1, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], new_hash,
|
|
|
+# data4, data2['expire_time'], odds_only, 1, data2['utime'], data1, data2['expire_time'], odds_only,data4))
|
|
|
+# # 更新主队st_zq_odds_record表
|
|
|
+# sql2 = "insert into st_zq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only, is_today) values (%s,%s,%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s);"
|
|
|
+# cursor.execute(sql2, (
|
|
|
+# int(data2['league_id']), data3, int(data2['game_id']), data2['utime'], data2['utime'], data1,
|
|
|
+# data2['p_id'], data2["p_code"], data2['sort'], data2["source"], data4, odds_only, 1))
|
|
|
+#
|
|
|
+# sql3 = "insert into st_zq_result(match_id, match_score, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_winer, update_time, match_time,match_process,tag,lg_id,u_home_score,u_guest_score,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set update_time=%s,match_score=%s,match_time=%s,match_process=%s,home_score=%s,guest_score=%s;"
|
|
|
+# cursor.execute(sql3, (
|
|
|
+# int(data2['game_id']), data2['match_score'],data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','','',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['league_id']),0,0,'hg3535',data2["p_code"],data2['utime'],data2['match_score'],data2['time_game'],data2['half_way'],data2['score_home'],data2['score_guest']
|
|
|
+# ))
|
|
|
+#
|
|
|
+# sql4 = "insert into st_zq_result_record(lg_id, home_team, guest_team, home_score, guest_score, all_goal, status, first_score, last_score, match_score, match_winer, update_time, match_time,match_process,tag,match_id,source,p_code) values (%s,%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s);"
|
|
|
+# cursor.execute(sql4, (
|
|
|
+# int(data2['league_id']), data2['team_home'],data2['team_guest'],data2['score_home'],data2['score_guest'],data2['number'],1,'','',data2['match_score'],'',data2['utime'],data2['time_game'],data2['half_way'],data2['number'],int(data2['game_id']),'hg3535',data2["p_code"]
|
|
|
+# ))
|
|
|
+#
|
|
|
+#
|
|
|
+# def zqone_competitions(data, cursor):
|
|
|
+# Competition_sql = "insert into st_zq_competition(home_team, guest_team, lg_id, status, match_id, match_date, match_time, ctime, utime,tag, source,type,expire_time,us_time,is_rollball) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s,%s,%s,%s,%s,%s) on conflict(match_id) do update set utime = %s,status=%s,tag=%s,expire_time=%s;"
|
|
|
+# cursor.execute(Competition_sql, (
|
|
|
+# data['team_home'], data['team_guest'], data['league_id'],1,data['game_id'], data['match_date'],
|
|
|
+# data['match_time'],
|
|
|
+# data['utime'], data['utime'], data['number'], data["source"], 4,data['expire_time'], data['us_time'],data['is_rollball'],
|
|
|
+# data['utime'], 1, data['number'], data['expire_time']))
|
|
|
+#
|
|
|
+#
|
|
|
+# def get_pcodes(corner_ball, code):
|
|
|
+# code_dict = {'concede_size': 1, 'capot': 2, 'two_sides': 3, 'total_goal': 4, 'half_full': 5, 'bodan': 6,
|
|
|
+# 'first_last_ball': 7, 'temaball': 11}
|
|
|
+# if corner_ball == "角球":
|
|
|
+# p_code = "corner_ball"
|
|
|
+# p_id = 9
|
|
|
+# elif corner_ball == "会晋级":
|
|
|
+# p_code = "promotion"
|
|
|
+# p_id = 10
|
|
|
+# elif corner_ball == "罚牌数":
|
|
|
+# p_code = "Penalty_card"
|
|
|
+# p_id = 12
|
|
|
+# else:
|
|
|
+# p_code = code
|
|
|
+# p_id = code_dict[code]
|
|
|
+# return p_code, p_id
|
|
|
+#
|
|
|
+#
|
|
|
+# def news_times(ctime):
|
|
|
+# time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
|
|
|
+# time2 = time.localtime(time1)
|
|
|
+# time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
|
|
|
+# time4 = time3
|
|
|
+# data_time = str(time4).split(" ")
|
|
|
+# match_date = data_time[0]
|
|
|
+# match_time = data_time[1]
|
|
|
+# return match_date, match_time, time3
|
|
|
+
|
|
|
+# def new_times(ctime):
|
|
|
+# time1 = time.mktime(time.strptime(ctime, '%Y-%m-%d %H:%M:%S')) + 43200
|
|
|
+# time2 = time.localtime(time1)
|
|
|
+# time3 = time.strftime('%Y-%m-%d %H:%M:%S', time2)
|
|
|
+# data_time = str(time3).split(" ")
|
|
|
+# match_date = data_time[0]
|
|
|
+# match_time = data_time[1]
|
|
|
+# return match_date,match_time
|