0
votes

I use python to process web page. I download the souce code of the page. And I want to store the code in sqlite. And it raise the Exception.

sql = """insert into warrent(link, content) values ('%s', '%s')""" % (url, page) self.curs.execute(sql)

2

2 Answers

0
votes

I also ran into the same problem. The solution is quite simple. Do this before making "sql" string:

url = '"'+url+'"'

The problems arises because inside the string the " symbol is not present sql sees it as a command rather than as a string.

-1
votes

try the following:

sql = "INSERT INTO warrent(link, content) values (\'{0}\', \'{1}\')".format(url,page)
self.curs.execute(sql)

In your example \' won't the ":" from url.

Cheers, Jakub