项目描述:
想把status状态为1的数据查出来然后再通过while 遍历update 数据,为了清楚测试时候的数据。
刚开始的代码是这样的。
#coding:utf-8
import pymssql
def connect():
connect=pymssql.connect((‘x.x.x.x’),‘x’,‘x’,‘x’)
cursor = connect.cursor() # 创建游标
sql001='select *from xxxxx where xxxxx=273and Status=1 order by sysno desc'#查询语句
cursor.execute(sql001)
row=cursor.fetchone()#读取查询结果
print(row)
if row==None:
print("没有查到数据")
else:
while row:
print("sysno=%s" % (row[0]))
cursor.execute("update xxxxx set Status=-1 where SysNo=%d", row[0]) # 执行语句\
connect.commit()
print(row)
#cursor.execute(sql001)
row=cursor.fetchone()
#print(row)
connect()
报错信息:
File “D:/JiCaiZhuanTi/Case/test.py”, line 22, in connect
row=cursor.fetchone()
File “src\pymssql.pyx”, line 507, in pymssql.Cursor.fet