def appendCons(totalSql, count, pankou, linchangpankou, conds, constr, database, colName, colValue): rArr = [[' AND zhubifen>kebifen ', '胜'], [' AND zhubifen=kebifen ', '平'], [' AND zhubifen<kebifen ', '负'], [' AND (zhubifen-kebifen-pankou)*pankou>0 ', '上盘'], [' AND (zhubifen-kebifen-pankou)*pankou<0 ', '下盘']] for index in range(len(rArr)): i = rArr[index] countSql = totalSql + i[0] pCount = DB.queryCount(database, countSql) if pCount is not None: if index < 3 and _ouPeiMap[pankou][index] * (pCount / count) < 1.3: continue elif index >= 3 and pCount / count < 0.7: continue print(('盘口:%s,临场盘口:%s,类型:%s,总场次:%s,命中场次:%s,比例:%s') % (pankou, linchangpankou, i[1], count, pCount, round(pCount / count, 3))) conTemp = [ pankou, linchangpankou, constr.strip(), index + 1, count, pCount, round(pCount / count, 3), colName, colValue ] conds.append(conTemp) return conds
def queryCount(database,pankou,linchangpankou,conditionStrs,index,bisaishijian): orginSql = 'SELECT count(1) FROM football_data WHERE 1=1 AND pankou=%s AND bisaishijian<="%s" '%(pankou,'2019-09-01') constr = '' for i in conditionStrs: constr = constr+ ' '+ i + ' ' orginSql +=constr totalCount = database.execQuery(orginSql)[0][0] rArr = [[' AND zhubifen>kebifen ', '胜'], [' AND zhubifen=kebifen ', '平'], [' AND zhubifen<kebifen ', '负'], [' AND (zhubifen-kebifen-pankou)*pankou>0 ', '上盘'], [' AND (zhubifen-kebifen-pankou)*pankou<0 ', '下盘']] if totalCount<20: return None,None # for index in range(len(rArr)): i = rArr[index] countSql = orginSql + i[0] pCount = DB.queryCount(database, countSql) return totalCount,pCount
def printResult(totalSql, condStr, database): countSql = totalSql + condStr count = DB.queryCount(database, countSql) return count