Python MySQL查询用updated_at替换created_at

时间:2016-03-07 22:16:28

标签: python mysql

我有以下Python MySQL查询:

sql = "INSERT INTO Tweets(timestamp, message_id, body, username, symbol_id, created_at, updated_at) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s') ON DUPLICATE KEY UPDATE timestamp=VALUES(timestamp), message_id=VALUES(message_id), body=VALUES(body), username=VALUES(username), symbol_id=VALUES(symbol_id), created_at=NOW(), updated_at=NOW()"% \
(timestamp, messageId, body, username, dbID, currentTime, currentTime)

一切正常,直到我点击ON DUPLOCATE KEY UPDATE updated_atNOW()时间戳替换。我尝试删除currentTimeupdated_at=NOW(),但会收到以下错误:

Traceback (most recent call last):
  File "./parseTweets.py", line 50, in <module>
    (timestamp, messageId, body, username, dbID, currentTime)
TypeError: not enough arguments for format string

我不希望updated_at替换为created_at,如果它只是更新行

0 个答案:

没有答案