我已经从sqllite表创建了一个tmp表,它是基于各种选择条件的原始表的子集。截图中有一个样本。
我试图一次循环遍历一个表记录,以便更新每个记录中的一个字段。我有:
source_table= self.source
engine = create_engine(db_path)
Base = declarative_base()
# metadata = Base.metadata
# Look up the existing tables from database
Base.metadata.reflect(engine)
# Create class that maps via ORM to the database table
table = type(source_table, (Base,), {'__tablename__': source_table})
Session = sessionmaker(bind=engine)
session = Session()
i = 0
for row in session.query(table).limit(500):
i += 1
print object_as_dict(row)
但这给了我们:
ArgumentError: Mapper Mapper|tmp|tmp could not assemble any primary key columns for mapped table 'tmp'
如何执行此循环?
目前没有回答
相关问题 更多 >
编程相关推荐