Esempio n. 1
0
def getuid(username):
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    cursor.execute("select UID from user where UserName = '******';" %(username))
    uid = cursor.fetchall()[0][0]
    db.close()
    return uid
Esempio n. 2
0
def reqState(username):
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    cursor.execute("""select State from user where UserName = '******'; """ %
                   (username))
    status = cursor.fetchall()[0][0]
    db.close()
    return status
Esempio n. 3
0
def outState(username):
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    cursor.execute("""update user set State = 0 where UserName = '******'; """ %
                   (username))
    db.commit()
    db.close()
    return
Esempio n. 4
0
def logIn(username):
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    cursor.execute("""select Password from user where UserName ='******'; """ %
                   (username))
    pw = cursor.fetchall()[0][0]
    db.close()
    return pw
Esempio n. 5
0
def dele(username, sid):
    UID =getuid(username)
    SID = sid
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    cursor.execute("delete from preferlist where SID = '%s' and UID =  '%s';" %(SID,UID))
    db.commit()
    db.close()
    return
def stockList():
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    cursor.execute(""" select * from stock ;""")
    all = cursor.fetchall()
    data = '['
    for i in all:
        data = data + str(i[0]) + ','
    data = data[:-1] + ']'
    return data
def allData(sid):
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    name = getTableName(sid)
    cursor.execute(""" select * from %s ;""" % (name))
    all = cursor.fetchall()
    data = ''
    for i in all:
        data = data + str(i[0]) + ':' + str(i[1]) + ','
    return data[:-1]
def periodData(timeStart, sid):
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    name = getTableName(sid)
    cursor.execute("""select * from %s
        where times=%d;""" % (name, timeStart))
    period = cursor.fetchall()
    data = ''
    for i in period:
        data = data + str(i[0]) + ':' + str(i[1]) + ','
    return data[:-1]
Esempio n. 9
0
def checkexist(username):
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    cursor.execute("""select count(*) from user where UserName = '******';""" %
                   (username))
    r = cursor.fetchall()[0][0]
    db.close()
    if r == 0:
        return 0
    else:
        return 1
Esempio n. 10
0
def req(username):
    UID = getuid(username)
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    cursor.execute("select SID from preferlist where UID = '%s'; " %(UID))
    d = cursor.fetchall()
    plist ='['
    if d != ():
        for i in d:
            plist = plist +i[0]+','
        plist = plist[:-1] +']'
    return plist
Esempio n. 11
0
def up(username, password):
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")
    cursor.execute("select count(*) from user;")
    num = cursor.fetchall()[0][0]
    id = num + 1
    uid = str(id)
    cursor.execute("""insert into user values('%s', '%s', '%s', default);""" %
                   (uid, username, password))
    db.commit()
    db.close()
    return
Esempio n. 12
0
def add(username, sid):
    UID = getuid(username)
    SID = sid
    db = connect.connect()
    cursor = db.cursor()
    cursor.execute("use stock_system;")

    cursor.execute("select count(*) from preferlist where SID = '%s' and UID =  '%s';" %(SID,UID))
    count = cursor.fetchall()[0][0]
    if count > 0:
        db.close()
        return
    else:
        cursor.execute("insert into preferlist values('%s', '%s');" %(UID,SID))
        db.commit()
        db.close()
        return