1

我从 sqlalchemy 开始,到目前为止我有

import sqlalchemy

db = sqlalchemy.create_engine('mysql://CONNECTION?charset=utf8&use_unicode=0')
connection = db.connect()
db.echo = True
metadata = sqlalchemy.MetaData(db)

details_file = sqlalchemy.Table('details_file', metadata, autoload=True)

query = details_file.select([details_file.c.Id]).\
        where(details_file.c.RunId == 5859)
res = query.execute()

我正在尝试的是只选择Id符合 where 标准的列。我怎样才能做到这一点?

4

1 回答 1

1

您直接使用select构造:

from sqlalchemy import select

select([details_file.c.Id]).where(details_file.c.runid == 5)
于 2013-02-24T18:12:48.237 回答