def __init__(self):
     dbconfig = {
       'host':'localhost', 
       'port': 3306, 
       'user':'******', 
       'passwd':'111111', 
       'db':'sport', 
       'charset':'utf8'
     }
 
     self._db = MySQL(dbconfig)
示例#2
0
class SportPipeline(object):

    _db = None

    def __init__(self):
        dbconfig = {
            'host': 'localhost',
            'port': 3306,
            'user': '******',
            'passwd': '123123',
            'db': 'testdj',
            'charset': 'utf8'
        }

        self._db = MySQL(dbconfig)

    def process_item(self, item, spider):
        insert_sql = "INSERT INTO calc_blogphoto  (guid,title,source_url,user_id,remote_images_paths,local_images_paths,remote_default_image,local_default_image) VALUES ('%s','%s','%s',%d,'%s','%s','%s','%s')" % (
            'aaaa', db_charset_to_utf8(item['title'][0]), item['source_url'],
            item['user_id'], '3', '33', '22', '13')

        id = self._db.insert(insert_sql)
        print('============================')
        print(id)
        print('============================')
        return item
class SportPipeline(object):
    _db = None

    def __init__(self):
        dbconfig = {
          'host':'localhost', 
          'port': 3306, 
          'user':'******', 
          'passwd':'111111', 
          'db':'sport', 
          'charset':'utf8'
        }
    
        self._db = MySQL(dbconfig)

    def process_item(self, item, spider):    
        insert_sql = "INSERT INTO sport_schedule(home_team,guest_team,home_logo,guest_logo,match_date,game_type) values \
                      ('%s','%s','%s','%s','%s','%s')" % (item['home_team'], item['guest_team'], item['home_logo'],\
                      item['guest_logo'], item['match_date'], item['game_type'])

        self._db.insert(insert_sql)
        return item