我想知道在提交失败后是否应该在SQLAlchemy中调用回滚?如果发生一些错误,我想继续保存对象。我不关心交易保存。
engine = create_engine("db", convert_unicode=True, echo=False)
Session = scoped_session(sessionmaker(bind=engine, autocommit=False))
for row in data:
try:
Session.add(row)
Session.commit()
except:
# rollback ???
# continue saving rest of the objects
continue
Session.remove()