pymysql-execute

sql = """INSERT INTO measureinfo(DateStr,DeviceIndex,PayIndex, Hight, Weight, BMI, BodyTem, BPL, BPH) 
VALUES (%s,%s, %s, %s, %s, %s,%s,%s,%s)"""
para = (123,msg[5:13], msg[13:24], msg[24:28], msg[28:32], msg[32:35], msg[35:38], msg[38:42], msg[42:46])
cursor.execute(sql, para)

无论mysql字段是什么类型,占位符一律使用%s,execute的参数可以是 列表,元祖,字符形式
‘The format string is not really a normal Python format string. You must always use %s for all fields’
posted on 2019-02-12 09:42  jak06  阅读(601)  评论(0编辑  收藏  举报