如何检索 SQLAlchemy 结果集的 Python 列表?

10 浏览
0 Comments

如何检索 SQLAlchemy 结果集的 Python 列表?

我有以下查询来检索单个数据列:

routes_query = select(
    [schema.stop_times.c.route_number],
    schema.stop_times.c.stop_id == stop_id
).distinct(schema.stop_times.c.route_number)
result = conn.execute(routes_query)
return [r['route_number'] for r in result]

我想知道是否有更简洁的方法来检索返回的数据行的本地列表。

0