_mysql数据库_异常操作错误:(1054,“字段列表”中的“BOBPC”列未知)

2024-09-20 01:27:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我好像找不到我做错了什么。如果能收到一些反馈,那就太好了!在

    import cgi, cgitb, MySQLdb
    cgitb.enable()
    db = MySQLdb.connect(db="watchdog",user="root",passwd="XXXXXXX")
    c = db.cursor()
    print ("Content-type:text/html\n")
    print ("<html><head><title>WatchdogServer</title></head><body>")
    data = cgi.FieldStorage()
    hostname = data.getvalue("hostname")
    osName = data.getvalue("osName")
    ramUsage = data.getvalue("ramUsage")
    cpuUsage = data.getvalue("cpuUsage")
    diskUsage = data.getvalue("diskUsage")
    c.execute("""CREATE TABLE IF NOT EXISTS `{}` (`ID` int(11) NOT NULL,`hostname` text NOT NULL,`osName` text NOT NULL,`ramUsage` text NOT NULL,`cpuUsage` text NOT NULL,`diskUsage` text NOT NULL,`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=latin1; """.format(hostname))
    c.execute("""INSERT INTO `{}` (`hostname`, `osName`, `ramUsage`, `cpuUsage`, `diskUsage`) VALUES (`{}`,`{}`,`{}`,`{}`,`{}`);""".format(hostname,hostname,osName,ramUsage,cpuUsage,diskUsage))
    print ("</body></html>")

由于某些原因,它正在寻找一个带有hostname变量的列。但是,即使我更改了所有的列名并再试一次,我还是每次都收到相同的错误。:(

_mysql_异常操作错误:(1054,“字段列表”中的“BOB-PC”列未知)

希望你们中的任何人都能帮助我!在

干杯! 鲍勃


Tags: textdbdatahtmlnotnullhostnamecgi