更新时间:2022-12-12 16:38:53
这应该有助于获得 falesie
的单一结果:
This should help with getting a single result of falesie
:
try:
user = session.query(falesie).filter(name=name).one() # filter on name
except MultipleResultsFound, e:
print e
# Deal with it
except NoResultFound, e:
print e
# Deal with that as well
哪里session
得到如下:
Where session
is obtained as following:
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
# an Engine, which the Session will use for connection resources
engine = create_engine('sqlite:///climb.db')
# create a configured "Session" class
Session = sessionmaker(bind=engine)
# create a Session
session = Session()
请参阅 SQLAlchemy
文档了解更多详情.
See SQLAlchemy
documentation for more details.