Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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_Mysql_Sql_Sqlalchemy - Fatal编程技术网

Python 如何通过SQLAlchemy获取列的值?

Python 如何通过SQLAlchemy获取列的值?,python,mysql,sql,sqlalchemy,Python,Mysql,Sql,Sqlalchemy,我想通过SQLAlchemy获取列的值,我知道我可以这样做: 例如: result = db.session.query(User.id).all() 但结果是一组列表 result = [(1),(2),(3).........] result = [i[0] for i in result] // how to omit this step? 但我希望直接得到一个列表([1,2,3…])或一个集合(1,2,3)。有人有好主意吗?似乎炼金术中没有任何方法

我想通过SQLAlchemy获取列的值,我知道我可以这样做:

例如:

result = db.session.query(User.id).all()
但结果是一组列表

result = [(1),(2),(3).........]
result = [i[0] for i in result] // how to omit this step?

但我希望直接得到一个列表([1,2,3…])或一个集合(1,2,3)。有人有好主意吗?

似乎炼金术中没有任何方法