for row in cursor.fetchall():
currentid = str(row[0])
links = soup.findAll('a', {'class':'lightboxImage'})
for link in links:
file_name = urllib2.unquote(url).decode('utf8').split('/')[-1]
#print ("<img src=\"http:" + str(link['href'] + "\"</img>"))
cursor.execute("INSERT INTO `Images`(`ImageURL`, `ProductID`) VALUES (" + "\"" + file_name + "\"" + " , " + currentid)
This is the error I'm getting when I run it.
root@eBayFileServer:~# python scrape.py
Traceback (most recent call last):
File "scrape.py", line 102, in <module>
cursor.execute("INSERT INTO `Images`(`ImageURL`, `ProductID`) VALUES (" + "\"" + file_name + "\"" + " , " + currentid)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1")
I have tried all sorts of things, like changing the quotes around the data, but I just can't figure it out.
VALUES (
lacks a corresponding close paren)
at the end. – Dan 41 mins ago)
both in quotes and out of quotes.+ ")")
. The first one is for MySql, the second one is for Python. – Dan 37 mins ago