Python 根据条件 更新MySQL数据库字段数据


# 导入MySQL
import pymysql

# 连接数据库
conn = pymysql.connect(host="111.111.111.111", user="11111", password="1111111", port=3306, db="11111",charset="utf8")

# 创建游标
cursor = conn.cursor()

"""根据last_sync_time字段更新数据为“2020-8-30 23:35:23”"""
# 语法为:" update 表名 set 字段 = ' 要更改的数据'"
sql = "update t_car_detail_city set last_sync_time = '2020-8-30 23:35:23'"

#  执行sql语句
cursor.execute(sql)
#  提交操作
conn.commit()
cursor.close()  # 关闭游标
conn.close()  # 关闭连接

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM