クエリ文字列を作成しています。
query = "SELECT seqid, date, name, steamid, team, text, type, '%s' as triggerword, '%s' as weight FROM chatlogs WHERE date > '%s' AND text LIKE '%%%s%%' ORDER BY DATE" % (word, weight, self.setting['LAST_RUN_TIME'], word)
文字列を出力すると、正しく返されます。
SELECT seqid, date, name, steamid, team, text, type, 'hunting_term' as triggerword, '0.01' as weight FROM chatlogs WHERE date > '2012-04-18 23:47:58.439124' AND text LIKE '%hunting_term%' ORDER BY DATE
ただし、TypeError 例外で失敗します: TypeError: フォーマット文字列の引数が不足しています
完全なコード:
import database
mysqldb = database.Connection('localhost','mydb',user='myuser',password='mypass')
word = 'hunting_term'
weight = 0.01
setting = dict({'LAST_RUN_TIME':'2012-04-18 23:47:58.439124'})
query = "SELECT seqid, date, name, steamid, team, text, type, '%s' as triggerword, '%s' as weight FROM chatlogs WHERE date > '%s' AND text LIKE '%%%s%%' ORDER BY DATE" % (word, weight, setting['LAST_RUN_TIME'], word)
print query
for message in mysqldb.query(query): # This is the line it throws the exception on
print "A row"
データベースはtornadoパッケージからのものです