Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用SQLAlchemy从表中检索结果_Python_Database_Sqlalchemy - Fatal编程技术网

Python 使用SQLAlchemy从表中检索结果

Python 使用SQLAlchemy从表中检索结果,python,database,sqlalchemy,Python,Database,Sqlalchemy,如何打印由返回的结果 session.query(User.name).filter(User.gender!=“male”) 这将返回表中的所有男性候选人。我想分别打印每个候选人的名字。 我需要为此包含for循环吗?来自 >>> for instance in session.query(User).order_by(User.id): ... print instance.name, instance.fullname ed Ed Jones wendy Wend

如何打印由返回的结果 session.query(User.name).filter(User.gender!=“male”)

这将返回表中的所有男性候选人。我想分别打印每个候选人的名字。 我需要为此包含for循环吗?

来自

>>> for instance in session.query(User).order_by(User.id): 
...     print instance.name, instance.fullname
ed Ed Jones
wendy Wendy Williams
mary Mary Contrary
fred Fred Flinstone