import pymssql
server = "192.168.1.1" # 连接服务器地址
persons = ""
password = ""
conn = pymssql.connect(server, persons, password, "databasename") #获取连接
cur = conn.cursor() # 获取光标
# 创建表
#查询
sel ='select * from persons'
cur.execute(sel)
data = cur.fetchall()
print(len(data))
for i in range(1,len(data)+1):
version = "update persons set name='amy' where id="+str(i)
cur.execute(version)
conn.commit()
#关闭
cur.close()
#关闭连接
conn.close()
如何批量修改数据库某列字段
最新推荐文章于 2022-11-26 22:02:38 发布