In my Flask web app I have a login system. When user logged, in the table of my database I want to update the datetime when user made the last login. I'm using this code:
@app.route('/login', methods=['POST'])
def do_admin_login():
POST_CODICE_FISCALE = str(request.form['codice_fiscale'])
POST_PASSWORD = str(request.form['password'])
pwd_enc=base64.b64encode(POST_PASSWORD)
Session = sessionmaker(bind=engine)
s = Session()
query = s.query(User).filter(User.codice_fiscale.in_([POST_CODICE_FISCALE]), User.password.in_([pwd_enc]))
result = query.first()
if result:
session['logged_in'] = True
query = s.query(User).filter(User.codice_fiscale.in_([POST_CODICE_FISCALE]).update(User.data_ora_ultimo_accesso=datetime.now()))
query.first()
db.session.commit()
else:
flash('wrong password!')
return home()
but I receive the error:
query = s.query(User).filter(User.codice_fiscale.in_([POST_CODICE_FISCALE]).update(User.
data_ora_ultimo_accesso=datetime.now()))
SyntaxError: keyword can't be an expression
what it is wrong? thanks.