python - SyntaxError: keyword can't be an expression
给我你的怀抱
给我你的怀抱 2017-05-18 10:56:29
0
2
3570
  1 # -*- coding:utf-8 -*-
  2 from Shares.sqlconn import *
  3 from sqlalchemy.orm import sessionmaker
  4 
  5 def CheckLogin(name,passwd):
  6     session = Session().get_session()
  7     flag = session.query(User).filter(User.name=name,User.passwd=passwd).one_or_none()                                                                                                       
  8     session.close()
  9     if flag:
 10         return True
 11     return False

I use sqlalchemy in django but filtering will report an error

  File "/root/Shares/user/check_login.py", line 7
    flag = session.query(User).filter(User.name=name,User.passwd=passwd).one_or_none()
SyntaxError: keyword can't be an expression

May I ask the masters how to solve it

给我你的怀抱
给我你的怀抱

reply all(2)
漂亮男人

The correct way to write it should be

flag = session.query(User).filter(User.name==name,User.passwd==passwd).one_or_none()

That’s it

黄舟

User.nameUser.passwd不是正确的参数名.可能是User_name,User_passwd. Please check the documentation of the relevant libraries for details

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template