The import time
The import urllib. Request
The import urllib. Parse
The import sqlite3
The import pymysql
If __name__=="__main__" :
Connmysql=pymysql. Connect (user='root' and password='123456', the database='empiredd' charset='utf8')
Cursormysql=connmysql. Cursor ()
='select query id, title, company, qikanname from table1'
Cursormysql. Execute (query)
For (id, title, company, qikanname) in cursormysql:
Print (id, title, company, qikanname)
Conn=sqlite3. Connect (r "E: \ web \ SpiderResult db3")
Cursor=conn. Cursor ()
SQL="select filename from table3 the where biaoti=? And the company=? And kanwu=?"
Cursor. The execute (SQL, title, company, qikanname))
Values=cursor. Fetchone ()
Print (values [0])
Print (id)
Cursormysql. Execute (' update table2 set downpath=? Where id=? '(values [0], id))
MIT ()
connmysql.comCursor. The close ()
Conn. Close ()
Cursormysql. Close ()
Connmysql. Close ()
Error is cursormysql execute (' update table2 set downpath=? Where id=? '(values [0], id)), very strange
CodePudding user response:
Website seems to have automatic transcoding, source code is as follows:The import time
The import urllib. Request
The import urllib. Parse
The import sqlite3
The import pymysql
If __name__=="__main__" :
Connmysql=pymysql. Connect (user='root' and password='123456', the database='empiredd' charset='utf8')
Cursormysql=connmysql. Cursor ()
='select query id, title, company, qikanname from table1'
Cursormysql. Execute (query)
For (id, title, company, qikanname) in cursormysql:
Print (id, title, company, qikanname)
Conn=sqlite3. Connect (r "E: \ web \ SpiderResult db3")
Cursor=conn. Cursor ()
SQL="select filename from table3 the where biaoti=? And the company=? And kanwu=?"
Cursor. The execute (SQL, title, company, qikanname))
Values=cursor. Fetchone ()
Print (values [0])
Print (id)
Cursormysql. Execute (' update table2 set downpath=? Where id=? '(values [0], id))
MIT ()
connmysql.comCursor. The close ()
Conn. Close ()
Cursormysql. Close ()
Connmysql. Close ()
CodePudding user response:
Print (values [0]) is the result of the STR type, the value of wxrokl4xnp2. PDFPrint (id) is the result of 60, these two values are correct,
CodePudding user response:
Cursormysql. Execute (' update table2 set downpath=? Where id=? '(values [0], id))Change
Cursormysql. Execute (' update table2 set downpath=? Where id=? '(values [0] [0], id))
Because values [0] is the first record of the result set, values [0] [0] is the first record that the value of the filename,
CodePudding user response:
In principle should not be an error, you have? Replaced with % s have a look, and the complete error message to be sent