python 将mysql数据库中的int类型修改为NULL 报1366错误,解决办法

 gt.run_sql()是用pymysql 封装的类

distribution_sort_id  type: int
目的:将此字段值全部修改为NULL
g=2
gt.run_sql("update goods set distribution_sort_id=%s;",(g,))
修改是成功的


g='null' or g="NULL"
gt.run_sql("update goods set distribution_sort_id=%s;",(g,))
会报1366错误

解决方法为
g=None
gt.run_sql("update goods set distribution_sort_id=%s;",(g,))
数据库字段distribution_sort_id 就被修改为Null了


猜你喜欢

转载自www.cnblogs.com/yanxiatingyu/p/10109891.html