![](/img/trans.png)
[英]Loading multiple instances from DB by a list of primary keys with SqlAlchemy
[英]Is there a workaround in sqlalchemy for loading a table from DB without any primary keys?
我有一种情况,我从旧数据库加载所有表。 但由于它没有任何主键,因此会出错。
任何人都可以给我这个错误的解决方案吗?
您可以将主键信息添加到自动加载的表中。
例如
class Subscrib(Base):
__tablename__ = 'mytable'
__table_args__ = {'autoload' : True}
thepk = Column(Integer, primary_key=True)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.