我选择并更新一行数据 sqlalchemy
,当我第二次执行时, sqlalchemy
什么也不还给我,为什么?
db_connection = 'mysql+pymysql://%s:%s@%s/%s?charset=utf8' % (db_user, db_pwd, db_host, db_name)
engine = create_engine(db_connection, echo=False)
session = sessionmaker(autocommit=False, autoflush=False, bind=engine)()
while True:
row = session.execute('select id, avi_id, address, code from job where job_status = :job_status', {'job_status': 'created'}).fetchone()
if row:
session.execute('update job set job_status = :job_status where id = :job_id', {'job_status': "finished", 'job_id': row[0]})
session.commit()
time.sleep(3)
然后我更新 job_status
进入 created
在mysql客户端上:
update job set job_status = "created" where job_status="finished"
第二个循环(第一个代码块),变量行没有,为什么?
暂无答案!
目前还没有任何答案,快来回答吧!