Пример #1
0
def zhuche(u, p):
    db = DBTool()
    sql = "select * from t_class where cname='{}'".format(u)
    sql2 = "insert into t_class(cname,teacher)values({},{})".format(u, p)
    res = db.query(sql)
    if u == '' or p == '':
        return None  #'注册失败,账号或密码不能为空'
    if res == False:  #查询数据库失败
        return False  #注册失败
    else:
        if len(res) == 0:
            db.commit(sql2)
            return '注册成功'
        else:
            return '注册失败,账号已存在'
Пример #2
0
def reg(username, password):
    if username == "" or password == "":
        print("用户名或密码格式不正确")
        return False

    # 查询用户是否已经注册注册了
    db = DBTool()
    sql = "select * from tbl_user where username='******'".format(username)

    if len(db.query(sql)) != 0:
        print("用户名已存在,不能重复注册!")
        return False
    else:
        sql = "INSERT INTO tbl_user VALUES('{}', '{}', 'f', 20)".format(
            username, password)
        if db.commit(sql) == True:
            print("注册成功!")
            return True
        else:
            print("注册失败!")
            return False