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

 

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

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了
相关文章
相关标签/搜索