mysql布尔值数据怎么添加_Pythonmysql.connector在mysql数据库中插入布尔值时出错

我在下面的表中声明了布尔值,在这里插入一个布尔值。在import urllib2

import mysql.connector as conn

import MySQLdb

import logging

class getData:

@staticmethod

def checkNetwork():

try:

urllib2.urlopen('https://www.google.com', timeout = 2)

return True

except urllib2.URLError as err:

return False

@staticmethod

def connectDB():

db = conn.connect(host='****', user='****', passwd='****', db='*******')

cursor = db.cursor()

return db,cursor

@staticmethod

def insertNData(data):

print type(data)

db,cursor = getData.connectDB()

sql_Query = "INSERT INTO Network(status) VALUES(%s);"

try:

result= cursor.execute(sql_Query,data)

db.commit()

logging.warn("%s", result)

logging.info("Success")

except MySQLdb.IntegrityError:

logging.warn("Failed")

finally:

db.close()

return True

netStat = getData.checkNetwork()

getData.insertNData(netStat)

当我运行代码时,我得到下面的错误ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s)' at line 1

我尝试在google上搜索以找到一些解决方案,还更改了一些要测试的内容,但仍然存在相同的错误。在

提前谢谢。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值