def check_frozen_compare(): sql = "select a.userId,a.balance,a.currency from spot_accounts a where a.type='SPOT_FROZEN'" config_ex = config_init("ex") conn = pymysql.connect(**config_ex) cur = conn.cursor() user_frozen = dict() user_frozen = check_useridfrozen() try: frozenset_sys = dict() cur = conn.cursor() cur.execute(sql) row = cur.fetchone() while row is not None: if row['userId'] is not None: userid = row['userId'] currency = row['currency'] id = repr(userid) + currency #print(id) #frozenset[id]=(row['userId'],row['currency'],row['balance']) #print (row['userId'],row['currency'],row['balance']) key = str(row['userId']) + row['currency'] list_frozen = [] list_frozen = user_frozen.get(key) #print(list_frozen) if list_frozen != None: amount = repr( list_frozen[2:3])[10:len(repr(list_frozen[2:3])) - 3] #print(amount, row['balance']) if float(row['balance']) == float(amount): print('SUCCESS用户' + str(row['userId']) + ",币种" + row['currency'] + '冻结金额比对一致!' + str(float(row['balance'])) + "," + str(float(amount))) str1 = "SUCCESS:冻结金额比对- - 用户" + str( row['userId'] ) + ",币种" + row['currency'] + '冻结金额比对一致!' else: print('ERROR用户' + str(row['userId']) + ",币种" + row['currency'] + '冻结比对不一致,请检查!' + str(float(row['balance'])) + "," + str(float(amount))) str1 = ' ERROR:冻结金额比对- - 用户' + str( row['userId'] ) + ",币种" + row['currency'] + '冻结金额比对不一致,请检查!' + str( float(row['balance'])) + "," + str(float(amount)) file_read_write.create_frozen_file(str1) #frozenset[id]=({"userid":row['userId'],"currency":row['currency'],"frozeen_amount":float(row['frozeen_amount'])}) #feerate[orderid]=(str(row['makerFeeRate_calculate']),row['makerFeeRate'],float(row['takerFeeRate_calculate']),float(row['takerFeeRate'])) row = cur.fetchone() except Exception as e: #cur.rollback() #cur.close() print('Error') raise e finally: cur.close() conn.close() return frozenset
def check_useridavailable(): #检查Match_Details中计算的费率及计价币种是否正确 config_ex = config_init("ex") conn = pymysql.connect(**config_ex) cur = conn.cursor() sql = data_sql_str.get_accountspotavailable() try: frozenset = dict() cur = conn.cursor() cur.execute(sql) row = cur.fetchone() while row is not None: a = [] if row['userid'] is not None: userid = row['userid'] currency = row['currency'] id = repr(userid) + currency #print(id) a.append(row['userid']) a.append(row['currency']) a.append(row['amount']) frozenset[id] = a #frozenset[id]=[row['userId'],row['currency'],row['amount']] #frozenset[id]=({"userid":row['userId'],"currency":row['currency'],"frozeen_amount":float(row['frozeen_amount'])}) #feerate[orderid]=(str(row['makerFeeRate_calculate']),row['makerFeeRate'],float(row['takerFeeRate_calculate']),float(row['takerFeeRate'])) row = cur.fetchone() except Exception as e: #cur.rollback() #cur.close() print('Error') raise e finally: cur.close() conn.close() return frozenset
def get_bind_GA_secret_fromdb(userid): """获取绑定GA时的secretKey""" conn_data = config_init("ui") conn = pymysql.connect(**conn_data) cur = conn.cursor() cur.execute(get_sql_str.get_bind_GA_secretkey(userid)) secret = cur.fetchone().get("bindData") cur.close() print("secret", secret) return secret
def get_ongoing_ieoid(): """获取状态为进行中的ieoId""" conn_data = config_init("ieo") conn = pymysql.connect(**conn_data) cur = conn.cursor() sql = get_sql_str.get_ongoing_ieoId() cur.execute(sql) result = cur.fetchone() print("result:", result) return result
def get_phoneNumber_by_userid(userid): """根据userid获取绑定的手机号""" conn_data = config_init("ex") conn = pymysql.connect(**conn_data) cur = conn.cursor() sql = get_sql_str.get_phoneNumber_by_userid(userid) cur.execute(sql) result = cur.fetchone() cur.close() print("result", result) return result
def get_user_GA_secret(userid): """根据userid获取已绑定的secretKey""" conn_data = config_init("ui") conn = pymysql.connect(**conn_data) cur = conn.cursor() sql = get_sql_str.get_user_GA_secret(userid) cur.execute(sql) result = cur.fetchone() print("result", result) cur.close() return result
def get_userid_by_phoneNumber(phoneNumber): """根据手机号获取绑定的userid""" conn_data = config_init("ex") conn = pymysql.connect(**conn_data) cur = conn.cursor() # sql = "SELECT id FROM `users` WHERE phone_number = "+repr(phoneNumber) sql = get_sql_str.get_userid_by_phoneNumber(phoneNumber) cur.execute(sql) result = cur.fetchone() cur.close() print("result", result) return result
def update_table_data(db_name, execute_sql): """更新数据库表数据""" db_name_config = config_init(db_name) conn = pymysql.connect(**db_name_config) try: global cur cur = conn.cursor() cur.execute(execute_sql) conn.commit() except Exception as e: print("error" + str(e)) raise e finally: cur.close() conn.close()
def get_conn_to_db(db_name, query_sql): """根据db_name,query_sql连接数据库并返回查询结果""" db_name_config = config_init(db_name) conn = pymysql.connect(**db_name_config) try: global cur cur = conn.cursor() cur.execute(query_sql) row = cur.fetchone() except Exception as e: print("error" + str(e)) raise e finally: cur.close() conn.close() print("row = " + str(row)) return row
def get_vcode(email): sql = get_sql_str.get_register_code(email) config_ui = config_init("ui") conn = pymysql.connect(**config_ui) try: cur = conn.cursor() cur.execute(sql) row = cur.fetchone() print(row) if row['email'] is not None: code = row['code'] except Exception as e: print('Error') raise e finally: cur.close() conn.close() return code
def check_available_compare(): sql = "select a.userId,a.balance,a.currency from spot_accounts a where a.type='SPOT_AVAILABLE'" config_ex = config_init("ex") conn = pymysql.connect(**config_ex) cur = conn.cursor() user_frozen = dict() user_frozen = check_useridavailable() try: frozenset_sys = dict() cur = conn.cursor() cur.execute(sql) row = cur.fetchone() while row is not None: if row['userId'] is not None: userid = row['userId'] currency = row['currency'] id = repr(userid) + currency #print(id) #frozenset[id]=(row['userId'],row['currency'],row['balance']) #print (row['userId'],row['currency'],row['balance']) key = str(row['userId']) + row['currency'] list_frozen = [] list_frozen = user_frozen.get(key) #print(list_frozen) if list_frozen != None: amount = repr( list_frozen[2:3])[10:len(repr(list_frozen[2:3])) - 3] #print(amount, row['balance']) #print(str(row['userId'])+"TTTTTTTTT",userid,currency) print("{} | {}".format(row, amount)) if float(row['balance']) == float(amount): print('SUCCESS:可用金额比对- - 用户' + str(row['userId']) + ",币种" + row['currency'] + '可用量比对一致!' + str(float(row['balance'])) + "," + str(float(amount))) str1 = "SUCCESS:可用金额比对- - 用户" + str( row['userId'] ) + ",币种" + row['currency'] + '可用量比对一致!' + str( float(row['balance'])) + "," + str(float(amount)) else: print(' ERROR:可用金额比对- - 用户' + str(row['userId']) + ",币种" + row['currency'] + '可用量比对不一致,请检查!' + str(float(row['balance'])) + "," + str(float(amount))) str1 = ' ERROR:可用金额比对- - 用户' + str( row['userId'] ) + ",币种" + row['currency'] + '可用量比对不一致,请检查!' + str( float(row['balance'])) + "," + str(float(amount)) file_read_write.create_available_file(str1) row = cur.fetchone() except Exception as e: #cur.rollback() #cur.close() print('Error') raise e finally: cur.close() conn.close() return frozenset