我目前有一个MySQL表,如下所示:
mysql> SELECT * FROM settings;
+--------------+-------+
| name | value |
+--------------+-------+
| connected | 0 |
+--------------+-------+
我正在尝试使用此代码通过Python连接的时间戳更新值:
db1 = MySQLdb.connect(host="localhost", user="user", passwd="password", db="database")
cursor1 = db1.cursor()
cursor1.execute("UPDATE settings SET value = 'ts' WHERE name = connected")
db1.commit()
cursor1.close()
这回到我身边:
cursor1.execute(“”“UPDATE settings SET value ='ts'WHERE name = connected”“”)
文件“/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py”,第174行,执行中
self.errorhandler(self,exc,value)
文件“/usr/lib/python2.7/dist-packages/MySQLdb/connections.py”,第36行,在defaulterrorhandler中 提出错误类,错误值 _mysql_exceptions.OperationalError:(1054,“在'where子句中'未知列'连接'”)
我无法理解。任何帮助都会非常感激。
答案 0 :(得分:1)
1054,"未知列'已连接'在' where子句'
此错误明确指出function sendEmails() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('2016.2');
var clientesInfo = sheet.getRange(2, 7, sheet.getLastRow() - 1, 2).getValues();
//Data de hoje na coluna G2;
for (var i = 0; i < clientesInfo.length; i++) {
if (clientesInfo[i][1] < 5 && clientesInfo[i][1] >= 0 ) {
MailApp.sendEmail("roger@tr.br", "Atenção! Prazo se esgotando(Isso é apenas um teste)", "Verifique tarefas que estão próximas de vencer, em: https://g.gl/plgTRU7");
} `enter code here`
}
}
被视为列名。
但此处connected
是要与列名connected
匹配的字符串值。
因此,您需要在name
字符串周围放置一个引号来解决问题:
connected