のときにTypeError: 'str' object is not callable
エラー メッセージが表示されます
INSERT INTO database
。
使用しています: Python 2.7.5、Scrapy 0.18、データベース MySQL
私のトレースバックは次のとおりです。
Traceback (most recent call last):
File "C:\python27\lib\threading.py", line 781, in __bootstrap
self.__bootstrap_inner()
File "C:\python27\lib\threading.py", line 808, in __bootstrap_inner
self.run()
File "C:\python27\lib\threading.py", line 761, in run self.__target(*self.__args, **self.__kwargs)
--- <exception caught here> ---
File "C:\python27\lib\site-packages\twisted\python\threadpool.py", line 191, in _worker
result = context.call(ctx, function, *args, **kwargs)
File "C:\python27\lib\site-packages\twisted\python\context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "C:\python27\lib\site-packages\twisted\python\context.py", line 81, in callWithContext
return func(*args,**kw)
File "C:\python27\lib\site-packages\twisted\enterprise\adbapi.py", line 448, in _runInteraction
result = interaction(trans, *args, **kw)
File "apple\pipelines.py", line 49, in _conditional_insert
'INSERT INTO job (id, company, day, hour, job, car1, car2) values (%s, %s, %s, %s, %s, %s)' ("company, day, hour, job, car1, car2 ")
exceptions.TypeError: 'str' object is not callable
これは私のコードスクリプトです:
def _conditional_insert(self, tx, item):
# create record if doesn't exist.
# all this block run on it's own thread
tx.execute('select * from job where hour = %s', ("item['hour'], "))
result = tx.fetchone()
if result:
log.msg("Item already stored in db: %s" % item, level=log.DEBUG)
else:
tx.execute(\
'INSERT INTO job (id, company, day, hour, job, car1, car2) values (%s, %s, %s, %s, %s, %s)' ("company, day, hour, job, car1, car2 ")
)
log.msg("Item stored in db: %s" % item, level=log.DEBUG)
def handle_error(self, e):
log.err(e)
そのエラーを解決するために何ができるか考えていますか?