Я не понимаю, почему я получаю синтаксическую ошибку здесь ... я не нахожу ничего неправильного и без пробелов ...
/pipelines.py", line 23
except MySQLdb.Error, e:
^
SyntaxError: invalid syntax
Ошибка здесь
и вот мой код
import sys
import MySQLdb
import hashlib
from scrapy.exceptions import DropItem
from scrapy.http import Request
class AmazonMobileDetailsPipeline(object):
def __init__(self):
self.conn = MySQLdb.connect('localhost', 'xxx', 'xxxxx', 'xxx', charset="utf8", use_unicode=True)
self.cursor = self.conn.cursor()
def process_item(self, item, spider):
try:
self.cursor.execute("""INSERT INTO items (name, price, imagelink) VALUES (%s, %s, %s)""", (item['mobile_name'].encode('utf-8'), item['mobile_price'].encode('utf-8'), item['mobile_imagelink'].encode('utf-8')))
self.conn.commit()
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
return item