给定Posts表和Post实例的集合,我想将所有实例插入Posts表。
我用:
def add_posts(self,posts):
for post in posts:
self.session.merge(post)
self.session.commit()
是否可以选择不迭代地执行此操作?例如:
def add_posts(self,posts):
self.session.**merge_all**(posts)
self.session.commit()