1 Star 0 Fork 0

hansdq / 爬虫学习

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
store.py 772 Bytes
一键复制 编辑 原始数据 按行查看 历史
import pymysql
class store:
coon = None
def init():
store.coon = pymysql.connect(
host = '127.0.0.1',
user = 'root',
password = 'Qing0815!',
db = 'tomorrow',
charset = 'utf8',
cursorclass = pymysql.cursors.DictCursor
)
def save(info):
try:
with store.coon.cursor() as cursor: # 执行完毕返回的结果集默认以元组显示
cursor.executemany('insert into content (title,text) values(%s,%s)',info) #执行SQL语句
store.coon.commit() #提交
return True
except:
return False
#cursor.close() #关闭光标对象
#store.coon.close() #关闭SQL连接
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hansdq/pachongxuexi.git
git@gitee.com:hansdq/pachongxuexi.git
hansdq
pachongxuexi
爬虫学习
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891