我开始使用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()
我尝试的是只选择符合where标准的列Id
。
我怎样才能做到这一点?
答案 0 :(得分:0)
直接使用select构造:
from sqlalchemy import select
select([details_file.c.Id]).where(details_file.c.runid == 5)