使用update()函数后,不使用session的SqlAlchemy提交

2024-09-30 08:22:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我的选择有效,但我的更新和删除不起作用。在

db_jb = create_engine(jb)
self.jobs = Table('Job', MetaData(jb), autoload=True)
# select - works
ss = select(self.jobs).where(
    self.jobs.c.job_guid == jobGuid
).limit(1)
rs = ss.execute()
rows = [r for r in rs]
rs.close()
# update - does not work
su = update(self.jobs, mysql_limit=1).where(
    self.jobs.c.job_guid == jobGuid
).values(jobStatus=status)
# does not have an affect
su.execution_options(autocommit=True)
rs = su.execute()
rs.close()

修改su变量,查询是正确的,但它没有被提交

^{pr2}$

如何在不使用会话的情况下提交更改?在


Tags: selftruecloseexecutejobsjobwhereselect

热门问题