Example #1
0
def drop_userdb(user):
    Session = sessionmaker(bind=engine)
    s = Session()
    r = s.query(User).filter_by(username=user)
    if r:
        result = r.first()
        if result:
            s.delete(result)
    s.commit()
Example #2
0
def action():
    result = request.form.get("result")
    id = int(request.form.get("id"))
    rw = ''
    if check_answer(id, result):
        rw = "Correct"
        Session = sessionmaker(bind=engine)
        s = Session()
        our_user = s.query(User).filter_by(username=session['user']).first()
        our_user.answers += 1
        s.commit()
    else:
        rw = "Incorrect"
    return render_template('answer.html', rw=rw, answer=data[id]['answer'])
Example #3
0
def add_user(user, passw):
    Session = sessionmaker(bind=engine)
    s = Session()
    new_user = User(username=user, password=passw, answers=int(0))
    s.add(new_user)
    s.commit()