python开发笔记MySQLdb

同事在开发的代码中执行某一条sql的时候总是会报warning:/usr/lib/python2.6/site-packages/pymysql/cursors.py:166: Warning: (u’1292’, u”Truncated incorrect DOUBLE value: ‘None’”),症状是server刚启动的时候会输出警告信息,之后就不会再输出了,结果也正确,但是看起来真的怪闹心的,并且在mycli中执行他的sql现象也是一样的,于是很好奇查了查原因,找到一篇问答 ,如下意思是,将字符串类型与数字类型进行了直接的比较导致的,查看原来的表结构以及sql语句后发现确实是,于是进行了sql语句的修改,之后问题修复

Look at this line "where PremiseID = " + str(premiseID) + " ; "])". The comparison is happening on different types and when MySQL compares different datatypes they are cast to DOUBLE internally before comparison. So you can try putting single quote around or cast around to solve the issue. So it’s not try catch but the quotes which resolve the issue.

 

转载请注明来源链接 http://just4fun.im/2016/12/23/python-e5-bc-80-e5-8f-91-e7-ac-94-e8-ae-b0mysqldb/ 尊重知识,谢谢:)