I've printed the output of my "payload" which I want to save to the MySQL database:
('B01MTOV8IP', '40462', '23.95', 'n/a', 'Usually ships in 24 hours',
'https://www.amazon.com/reviews/iframe?akid=AKIAIDCPAFSAQICDTFNQ&alinkCode=xm2&asin=B01MTOV8IP&atag=reakenture-20&exp=2017-08-25T17%3A27%3A37Z&v=2&sig=3zbBXVo4cQAJueFeVeo%252F%252FejvaUOmvuwAtfB4EfMyDiU%253D', 'CHG-GSTWL')
There seems to be something wrong with the way I am formatting it before I pass it to connect.
try:
selling_price = product.price_and_currency
selling_price_v = selling_price[0]#type
print selling_price_v
except Exception as e:
selling_price = "n/a"
conn = MySQLdb.connect(host="clabadmin.cfcudy1fdz8o.us-east-1.rds.amazonaws.com", user="", passwd="", db="")
payload =[
asin,
bsr,
str(selling_price_v),
str(listing_price_v),
# availability_type,
availability,
reviews,
sku]
print payload
# conn = sqlite3.connect('skubsr.db')
c = conn.cursor()
c.execute("""UPDATE webservice_bsr
SET
AISN = %s,
Best_Sellers_Rank = %s,
selling_price = %s,
price = %s,
# availability_type = %s,
availability = %s,
reviews = %s
WHERE ItemSKU = %s""", payload)
conn.commit()
I get the following error:
Traceback (most recent call last):
File "/home/trackstarz/clabReportScraper/bsrimport.py", line 907, in <module>
WHERE ItemSKU = %s""", payload)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 187, in execute
query = query % tuple([db.literal(item) for item in args])
TypeError: not enough arguments for format string
[Finished in 3.1s with exit code 1]
%sin your query, butpayloadhas only 7 elements. A#doesn't comment out part of the query; it would simply produce a syntax error ifc.executeactually tried to send it to the database.