Code snippet:
" SELECT * from webpage where url = '%s ' " % b try: cursor.execute (Sql_url) = Cursor.fetchall () except Exception, E: print E Pass
System: CentOS
Language: Python
Error message:
" You have a error in your SQL syntax; check the manual, corresponds to your MySQL server version for the right SYN tax-to-use-near "on line 1")
The error message says there is a syntax bug near ' "',
But most of the data ran smoothly, and then I printed out the data at the wrong time and found that the URL was followed by xxx= ' xxxxxxxx '
So plug this URL into the SQL statement and it becomes a select * from webpage where url = ' http://www.baidu.com/index.html?xxx= ' xxxxxxxxx '
Haha, did you see that?
After the single quotation mark of that parameter and the URL after the single quotation mark merge together, originally is 2, the result is 1.
The correct wording is:
' SELECT * from webpage where url = '%s ' ' % b
MySQL Select error