SQLAlchemy 连接 - return 一个 table 的所有列

SQLAlchemy join - return all columns of one table

我目前正在加入两个 tables returning 行,其中列在列表中:

a = Table('a', server_metadata, autoload=True)
b = Table('b', server_metadata, autoload=True)

tickers = ['1', '2']
res = b.join(a).select().where(asset.c.code.in_(tickers)).execute()

这 return 是 ab 中的正确行和所有列。我怎样才能只 return table b 的所有列?

select corresponds to the SELECT ... part of the SQL query, and defaults to *; to limit it to b.*, you can give it a list containing the table b; with this construct however you need to wrap the FROM part into select_from 否则 SQLAlchemy 将生成一个子查询片段。因此:

res = select([b]).select_from(b.join(a).\
    where(asset.c.code.in_(tickers))).execute()