예제 #1
0
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()
예제 #2
0
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)
예제 #3
0
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!")
예제 #4
0
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)
예제 #5
0
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")