The spider and pipeline are running fine but the database still shows empty set. Here is the pipeline code. I am using python 2.7 and mysql database
from twisted.enterprise import adbapi
class MysqlWriter(object):
def __init__(self):
self.dbpool = adbapi.ConnectionPool('MySQLdb',
db='applications',host='localhost',user='root',
passwd='root',charset='utf8',use_unicode=True)
def close_spider(self,spider):
self.dbpool.close()
def process_item(self, item, spider):
try:
yield self.dbpool.runInteraction(self.do_replace, item)
#yield cnx.runInteraction(self.do_replace, item)
except:
print traceback.format_exc()
defer.returnValue(item)
def do_replace(tx, item):
sql = """Insert INTO analytics (url, title) VALUES (%s, %s)"""
args = (item["url"][0], item["title"][0])
tx.execute(sql, args)