python爬虫 - Python 爬虫抓取网页数据,不能插入数据库中,求指点???
大家讲道理
大家讲道理 2017-04-17 15:47:39
0
4
387
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(4)
PHPzhong

I didn’t read the code carefully, but the obvious problem is that there is no commit transcation after the insert statement’s executeinsert语句的execute之后没有commit transcation

解决方法:

cur.execute('insert into ipList(ipList) values(%s)', ip_list[j])

Solution:

Add 🎜 in the next line of cur.execute('insert into ipList(ipList) values(%s)', ip_list[j])
conn.commit()
Ty80

If there is no exception, then it must be the InnoDB engine used for the database, right?
You have to commit the transaction. After executing all the statements, add conn.commit()Try

小葫芦

After inserting, you can use the command line to query or insert to see whether the database will be locked. . Just know if the matter is not over yet

阿神

Or turn on automatic submissionconn.autocommit(True)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!