Пример #1
0
def selectcat():
    global arr
    arr=[]
    cur.execute("select * from cat")
    result=cur.fetchall()
    results=digui(result,0)
    return json.dumps(results)
Пример #2
0
def all():
    id=session.get('uid')
    print(id)
    cur.execute("select * from stu where uid=%s",(uid))
    result = cur.fetchall()
    db.commit()
    return json.dumps(result)
Пример #3
0
def update():
    name=request.args.get("name")
    age = request.args.get("age")
    sex = request.args.get("sex")
    id = request.args.get("id")
    cur.execute("update stu set name=%s,sge=%s,sex=%s where id=%s",(name,age,sex,id))
    db.commit()
    return "ok"
Пример #4
0
def jian():
    uname=request.form["uname"]
    cur.execute("select * from user where uname=%s",(uname))
    result=cur.fetchone()
    if(result):
        return "false"
    else:
        return "true"
Пример #5
0
def add():
    name=request.args.get("name")
    age = request.args.get("age")
    sex = request.args.get("sex")
    print(session.get("uid"))
    cur.execute("insert into stu(name,sge,sex,uid) values(%s,%s,%s,%s)",(name,age,sex,uid));
    db.commit()
    return "ok"
Пример #6
0
def submit():
    uname=request.form["uname"]
    upsd = request.form["upass"]
    md5=hashlib.md5()
    md5.update(upsd.encode())
    upsd=md5.hexdigest()
    cur.execute("insert into user(uname,upsd) values (%s,%s)",(uname,upsd))
    db.commit()
    return redirect("/login")
Пример #7
0
def delcat():
    cid=request.args.get("cid")
    cur.execute("select * from cat where pid=%s",(cid))
    result=cur.fetchone()
    if(result):
        return "no"
    else:
        cur.execute("delete from cat where cid=%s",(cid))
        db.commit()
        return "ok"
Пример #8
0
def addcat():
    cname=request.args.get("cname")
    chead = request.args.get("chead")
    ctype = request.args.get("ctype")
    uid=request.args.get("uid")
    pid=request.args.get("pid")
    cur.execute("insert into cat(cname,chead,ctype,uid,pid) values(%s,%s,%s,%s,%s)",(cname,chead,ctype,uid,pid))
    cid=str(db.insert_id())  #在db.commit上边获取
    db.commit()
    return cid
Пример #9
0
def login1():
    uname = request.form["uname"]
    upsd = request.form["upass"]
    md5 = hashlib.md5()
    md5.update(upsd.encode())
    upsd = md5.hexdigest()
    cur.execute("select * from user where uname=%s and upsd=%s",(uname,upsd))
    result=cur.fetchone()
    global uid
    uid=result["id"]
    if(result):
        session["login"] = "******"
        session["uid"] = result["id"]
        session["uname"] = result["uname"]
        res=make_response(redirect("/"))
        return res
    else:
        return redirect("/logup")
Пример #10
0
def delete():
    id=request.args.get("id")
    cur.execute("delete from stu where id="+id);
    db.commit()
    return "ok"
Пример #11
0
def updatecat():
    cid=request.args.get("cid")
    cname = request.args.get("cname")
    cur.execute("update cat set cname=%s where cid=%s",(cname,cid))
    db.commit()
    return "ok"
Пример #12
0
def addhead():
    cid = request.args.get("cid")
    chead = request.args.get("chead")
    cur.execute("update cat set chead=%s where cid=%s", (chead, cid))
    db.commit()
    return "ok"
Пример #13
0
def selecthead():
    cid = request.args.get("cid")
    cur.execute("select chead from cat where cid=%s", (cid))
    result = cur.fetchone()
    result = result["chead"]
    return result
Пример #14
0
def listadd():
    cid = request.args.get("cid")
    ucon = request.args.get("ucon")
    cur.execute("insert into info(ucon,cid) VALUES (%s,%s)", (ucon, cid))
    db.commit()
    return "ok"
Пример #15
0
def listselect():
    cid = request.args.get("cid")
    cur.execute("select * from info where cid=%s", (cid))
    result = cur.fetchall()
    return json.dumps(result)