2013-02-21 57 views
0

選擇從元數據表中的列我開始與SQLAlchemy的,到目前爲止,我有在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。 我該如何做到這一點?

回答

0

您使用直接select結構:

from sqlalchemy import select 

select([details_file.c.Id]).where(details_file.c.runid == 5)