async def startApp(): global sql_conn sql_conn = db.db_set_connect(sql_settings["sql_ip"], sql_settings["sql_login"], sql_settings["sql_pass"], sql_settings["sql_db"]) WSconnect()
def save_acc_to_db(acc_data): global sql_conn if not db.save_acc(sql_conn, acc_data): sql_conn = db.db_set_connect(sql_settings["sql_ip"], sql_settings["sql_login"], sql_settings["sql_pass"], sql_settings["sql_db"]) save_acc(sql_conn, acc_data)
def save_quote_to_db(quote): global sql_conn if not db.save_quote(sql_conn, quote): sql_conn = db.db_set_connect(sql_settings["sql_ip"], sql_settings["sql_login"], sql_settings["sql_pass"], sql_settings["sql_db"]) if not db.save_quote(sql_conn, quote): print("DB add data error!")
async def clearOldQuotes(): global sql_conn while True: #sql_conn = db.db_set_connect(sql_settings["sql_ip"], sql_settings["sql_login"], sql_settings["sql_pass"], sql_settings["sql_db"]) if not db.clear_old_quotes(sql_conn): sql_conn = db.db_set_connect(sql_settings["sql_ip"], sql_settings["sql_login"], sql_settings["sql_pass"], sql_settings["sql_db"]) if not db.clear_old_quotes(sql_conn): print("DB clear data error!") await asyncio.sleep(3600)
async def startApp(): mdSession = socket.socket(socket.AF_INET, socket.SOCK_STREAM) global sql_conn sql_conn = db.db_set_connect(sql_settings["sql_ip"], sql_settings["sql_login"], sql_settings["sql_pass"], sql_settings["sql_db"]) global SeqNum SeqNum = 1 with mdSession: try: mdSession.connect((mdUAT.get('HOST'), mdUAT.get('PORT'))) mdSession.send(str(createMsg('logon', '')).encode('ascii')) await receiveFromSocket(mdSession) except socket.error as err: print(err) print("Error! Need to reconnect MD session")