Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:01:18+00:00 2026-06-08T08:01:18+00:00

I’m trying to get the scrapy pipeline working to funnel data into my db.

  • 0

I’m trying to get the scrapy pipeline working to funnel data into my db.
The problem I’m having is being unable to store a value for the primary field in my table that is “contentid.’ I’m using the variable current_affiliate_item but not having any luck.

Thanks in advance for your help!

File "/Users/pipelines.py", line 46, in _conditional_insert
    self.update_affiliate_item(tx, item, affiliate_item)
  File "/Users/pipelines.py", line 109, in update_affiliate_item
    current_affiliate_item['id'], #used to be this - current_affiliate_item['id']
exceptions.KeyError: 'id'

This is the code it is calling – beginning with line 46
ln 46 is – self.update_affiliate_item(tx, item, affiliate_item)
ln 109 is – current_affiliate_item[‘id’]

I don’t know what my problem is here, and have been stumped for days on it. I’m trying to call

        if affiliate_item:
        self.update_affiliate_item(tx, item, affiliate_item)
        item_affiliate_id = affiliate_item['id']
        item['affiliate_item_id'] = affiliate_item['id']
        item['id'] = affiliate_item['item_id'] 
    else:
        item['id'] = self.get_item_id(tx, item)
        item_affiliate_id = self.insert_affiliate_item(tx, item)

    # item_affiliate_id = self.insert_or_update_affiliate(tx, item)
    self.insert_or_update_photos(tx, item)

    for price in item['prices']: 
        self.insert_or_update_price(tx, item, item_affiliate_id, price)

    # log.msg("Item prices stored in db: %s" % item['name'], level=log.INFO)

def find_affiliate_item(self, tx, item): #changed selx to self
    tx.execute("select * from z2ah5_jreviews_content where affiliate_item_id = %s and jr_retailer = %s", (item['affiliate_item_id'], item['retailer']))
    result = tx.fetchone()
    if result:
        return result
    else:
        return False

def get_item_id(self, tx, item):
    tx.execute("select * from z2ah5_jreviews_content where slug = %s ", (item['slug']))
    result = tx.fetchone()
    if result:
        return result['contentid']
    else:
        tx.execute(\
            "insert into z2ah5_jreviews_content (name, slug, date_created, date_modified) "
            "values (%s, %s, %s, %s)",
            (
                item['name'],
                item['slug'],
                datetime.datetime.now(),
                datetime.datetime.now(), 
                )
            )
        return tx.lastrowid

def insert_affiliate_item(self, tx, item):
    tx.execute(\
        "insert into z2ah5_jreviews_content (item_id, jr_retailer, affiliate_item_id, jr_description, date_created, date_modified) "
        "values (%s, %s, %s, %s, %s, %s)",
        (
            item['id'],
            item['retailer'],
            item['affiliate_item_id'],
            item['desc'],
            datetime.datetime.now(),
            datetime.datetime.now()
            )
        )
    return tx.lastrowid

def update_affiliate_item(self, tx, item, current_affiliate_item): #used to be this - current_affiliate_item
    tx.execute(\
        "update z2ah5_jreviews_content set jr_description = %s, date_modified = %s where contentid = %s ",
        (
            item['desc'],
            datetime.datetime.now(),
            current_affiliate_item['id'], #used to be this -          current_affiliate_item['id']
            )               
        )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:01:20+00:00Added an answer on June 8, 2026 at 8:01 am

    The error is due to the fact that the dict affiliate_item does not have an ‘id’ key when you call the update_affiliate_item function

    instead of this

    if affiliate_item:
    

    try this:

    if affiliate_item and affiliate_item.has_key('id'):
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.