I have a project in which I have implement a Search Engine. Our guide suggested us to implement the code given in O' Reilly's Collective Intelligence 2007 book. This is a part of the code where a webpage is indexed. We are making use of Sqlite3 database. I get error in the last part of the code and even after researching a lot, I have had no success.
def addtoindex(self,url,soup):
if self.isindexed(url): return
print 'Indexing '+url
# Get the individual words
text=self.gettextonly(soup)
words=self.separatewords(text)
# Get the URL id
urlid=self.getentryid('urllist','url',url)
# Link each word to this url
for i in range(len(words)):
word=words[i]
if word in ignorewords: continue
wordid=self.getentryid('wordlist','word',word)
self.con.execute("insert into wordlocation(urlid,wordid,location)\values (%d,%d,%d)" % (urlid,wordid,i))
I am getting the following error in the last line:
sqlite3.OperationalError: unrecognized token: "[some symbol i don't know]"
Remove the backslash from the SQL command.
In Python, \v
specifies a control character (a vertical tab).