_mysql_exceptions.OperationalError:(1054,"未知栏' BOB-PC'在'字段列表'")

时间:2017-12-29 17:04:13

标签: python mysql python-3.x cgi mysql-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_exceptions.OperationalError:(1054,&#34; Unknown column&#39; BOB-PC&#39; in&#39; field list&#39;&#34;)

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

干杯! 鲍勃

0 个答案:

没有答案