示例#1
0
 def save_code(self,code):
     cur = conn.cursor(pymysql.cursors.DictCursor)
     cur.execute("select * from code where user=%s", self._userid)
     if cur.fetchone() is not None:
         cur.execute("update code set code = %s where user= %s", (code,self._userid))
     else:
         cur.execute("insert into code (user,code) value (%s,%s)", (self._userid,code))
     conn.commit()
     return True
示例#2
0
    def save_config(self,config):
        cur = conn.cursor(pymysql.cursors.DictCursor)
        cur.execute("select * from config where user=%s", self._userid)
        if cur.fetchone():
            cur.execute("update config set user = %s,name = %s,time_frame = %s, account = %s, password = %s, trading_mode = %s, symbols = %s where user=%s",
                        (self._userid,
                config[ 'name'],
                config[ 'time_frame'],
                config[ 'account'],
                config[ 'password'],
                config[ 'trading_mode'],
                config[ 'symbols'][0],self._userid))

        else:
            cur.execute("insert into config (user,name,time_frame, account, password, trading_mode, symbols) value (%s,%s,%s,%s,%s,%s,%s)", (self._userid,
                config[ 'name'],
                config[ 'time_frame'],
                config[ 'account'],
                config[ 'password'],
                config[ 'trading_mode'],
                config[ 'symbols'][0]))
        conn.commit()
        return True