我在Python 2.6上使用sqlalchemy 0.6.6和sqlite 3.6.22。當我這樣做:sqlalchemy查詢對象通過sqlite3返回Nones
In [1]: for i in ses.query(UserSnapshot):
...: print i
...: if i is None: break
...:
我看到:
...
<twopt.UserSnapshot object at 0x86a52f50>
<twopt.UserSnapshot object at 0x86a55050>
<twopt.UserSnapshot object at 0x86a55110>
<twopt.UserSnapshot object at 0x86a551d0>
<twopt.UserSnapshot object at 0x86a55290>
<twopt.UserSnapshot object at 0x86a55350>
None
我的架構:
傾銷我的整個數據庫,任何提示,以什麼可能導致None
的
class User(Base):
__tablename__ = 'user'
id = Column(Integer, primary_key=True)
blob = Column(LargeBinary, nullable=False)
since = Column(DateTime, nullable=False)
class UserSnapshot(Base):
__tablename__ = 'user_snapshot'
id = Column(Integer, primary_key=True)
uid = Column(Integer, ForeignKey(User.id), nullable=False)
blob = Column(LargeBinary, nullable=False)
time = Column(DateTime, nullable=False)
短,必須返回?我搜查了文檔,但找不到任何線索。謝謝。
您是否仍然在最新版本的sqlalchemy中看到此行爲?在寫這篇文章時,0.7.3是最新的穩定版本,許多bug在這裏和那裏都是固定的。 – SingleNegationElimination