当前位置: 首页 > news >正文

营销网站建设选择原则如何制作一个网站

营销网站建设选择原则,如何制作一个网站,青岛提供网站建设哪家便宜,wordpress上传视频教程python爬虫13:pymysql库 前言 ​ python实现网络爬虫非常简单,只需要掌握一定的基础知识和一定的库使用技巧即可。本系列目标旨在梳理相关知识点,方便以后复习。 申明 ​ 本系列所涉及的代码仅用于个人研究与讨论,并不会对网站产生…

python爬虫13:pymysql库

前言

​ python实现网络爬虫非常简单,只需要掌握一定的基础知识和一定的库使用技巧即可。本系列目标旨在梳理相关知识点,方便以后复习。

申明

​ 本系列所涉及的代码仅用于个人研究与讨论,并不会对网站产生不好影响。

目录结构

文章目录

    • python爬虫13:pymysql库
      • 1. 概述
      • 2. 方法
        • 2.1 模块:
        • 2.2 使用流程:
        • 2.3 Connection对象:
        • 2.4 Cursor对象:
        • 2.5 使用举例:
      • 3. 总结

1. 概述

​ pymysql是python与MySQL数据库进行交互的库,使用起来非常简单。虽然我用不到MySQL库,电脑重装系统后也没有安装它,但是考虑到可能有的人需要,所以还是说一下它。

​ 学习pymysql非常简单,重要的是要会MySQL的用法,不然单学这个库没啥用的。

2. 方法

2.1 模块:

pymysql

2.2 使用流程:

1. 创建connection
2. 获取cursor
3. 命令执行
4. 关闭cursor
5. 关闭connection

2.3 Connection对象:

该对象用于建立与数据库的连接

conn = pymysql.connect(参数列表)

​ 常用的参数:

参数host:			连接的mysql主机,如果本机是'localhost'
参数port:			连接的mysql主机的端口,默认是3306
参数database:		数据库的名称
参数user:			连接的用户名
参数password:		连接的密码
参数charset:		通信采用的编码方式,推荐使用utf8

​ 该对象的方法:

conn.close()		关闭连接
conn.commit()		提交(将所有的提交)
conn.cursor()		返回Cursor对象,用于执行sql语句并获得结果

2.4 Cursor对象:

​ 作用:

用于执行sql语句,使用频度最高的语句为select、insert、update、delete

​ 该对象的常用方法:

close()				关闭execute(operation [, parameters ])	执行语句,返回受影响的行数,主要用于执行insert、update、delete语句,也可以执行create、alter、drop等语句fetchone()		执行查询语句时,获取查询结果集的第一个行数据,返回一个元组fetchall()执行查询时,获取结果集的所有行,一行构成一个元组,再将这些元组装入一个元组返回

2.5 使用举例:

​ 例子一:

from pymysql import *def main():# 创建Connection连接conn = connect(host='localhost',port=3306,user='root',password='xxx',database='xxx',charset='utf8')# 获得Cursor对象cs1 = conn.cursor()# 执行select语句,并返回受影响的行数:查询一条数据count = cs1.execute('select id,name from goods where id>=4')# 打印受影响的行数print("查询到%d条数据:" % count)# for i in range(count):#     # 获取查询的结果#     result = cs1.fetchone()#     # 打印查询的结果#     print(result)#     # 获取查询的结果result = cs1.fetchall()print(result)# 关闭Cursor对象cs1.close()conn.close()if __name__ == '__main__':main()

​ 例子二:

from pymysql import *def main():# 创建Connection连接conn = connect(host='localhost',port=3306,database='xxx',user='root',password='xxx',charset='utf8')# 获得Cursor对象cs1 = conn.cursor()# 执行insert语句,并返回受影响的行数:添加一条数据# 增加count = cs1.execute('insert into goods_cates(name) values("硬盘")')#打印受影响的行数print(count)count = cs1.execute('insert into goods_cates(name) values("光盘")')print(count)# # 更新# count = cs1.execute('update goods_cates set name="机械硬盘" where name="硬盘"')# # 删除# count = cs1.execute('delete from goods_cates where id=6')# 提交之前的操作,如果之前已经之执行过多次的execute,那么就都进行提交conn.commit()# 关闭Cursor对象cs1.close()# 关闭Connection对象conn.close()if __name__ == '__main__':main()

3. 总结

​ 由于我没有安装MySQL库,上面的例子(我之前写过的代码)就没有配图,不过这个库是非常简单的,大家稍微看看应该就会了,没啥好说的。


文章转载自:
http://dinncolettic.bkqw.cn
http://dinncogreenstuff.bkqw.cn
http://dinncokidnap.bkqw.cn
http://dinncocaseose.bkqw.cn
http://dinncoamenorrhoea.bkqw.cn
http://dinncohyperacidity.bkqw.cn
http://dinncointerrogee.bkqw.cn
http://dinncopowerpoint.bkqw.cn
http://dinncosciophilous.bkqw.cn
http://dinncometralgia.bkqw.cn
http://dinncononhuman.bkqw.cn
http://dinncosystaltic.bkqw.cn
http://dinncogrowl.bkqw.cn
http://dinncopickax.bkqw.cn
http://dinncoratification.bkqw.cn
http://dinncowifehood.bkqw.cn
http://dinncoplonk.bkqw.cn
http://dinncoearlierize.bkqw.cn
http://dinncocephalocide.bkqw.cn
http://dinncotelecom.bkqw.cn
http://dinncoequanimously.bkqw.cn
http://dinncohypophysiotrophic.bkqw.cn
http://dinncobronchography.bkqw.cn
http://dinncoinflorescence.bkqw.cn
http://dinncobackfielder.bkqw.cn
http://dinncoepithalamus.bkqw.cn
http://dinncolifeboat.bkqw.cn
http://dinncoendocytose.bkqw.cn
http://dinncodiplomatic.bkqw.cn
http://dinncopuppetize.bkqw.cn
http://dinncochenag.bkqw.cn
http://dinncotampico.bkqw.cn
http://dinncoaltercate.bkqw.cn
http://dinncoxerophytism.bkqw.cn
http://dinncoschistose.bkqw.cn
http://dinncosandman.bkqw.cn
http://dinncofarthermost.bkqw.cn
http://dinncooneparty.bkqw.cn
http://dinncoadorable.bkqw.cn
http://dinncomotile.bkqw.cn
http://dinncorainband.bkqw.cn
http://dinncoglucosan.bkqw.cn
http://dinncoisohume.bkqw.cn
http://dinncolilliput.bkqw.cn
http://dinncoblankbook.bkqw.cn
http://dinncostridulation.bkqw.cn
http://dinncofortran.bkqw.cn
http://dinncoassembly.bkqw.cn
http://dinncosorgo.bkqw.cn
http://dinncochylific.bkqw.cn
http://dinncosubfebrile.bkqw.cn
http://dinncogelt.bkqw.cn
http://dinncononperishable.bkqw.cn
http://dinncoapo.bkqw.cn
http://dinncoalamanni.bkqw.cn
http://dinncoarrect.bkqw.cn
http://dinncobruvver.bkqw.cn
http://dinnconeedler.bkqw.cn
http://dinncofermi.bkqw.cn
http://dinncosherris.bkqw.cn
http://dinncotheatricality.bkqw.cn
http://dinncowaucht.bkqw.cn
http://dinncoresumptive.bkqw.cn
http://dinncogyration.bkqw.cn
http://dinncoempathy.bkqw.cn
http://dinncobaedeker.bkqw.cn
http://dinncolowborn.bkqw.cn
http://dinncopotamometer.bkqw.cn
http://dinncoclearsighted.bkqw.cn
http://dinncoretgersite.bkqw.cn
http://dinncomonoamine.bkqw.cn
http://dinncoadventurously.bkqw.cn
http://dinncochanger.bkqw.cn
http://dinncofoliage.bkqw.cn
http://dinncowendell.bkqw.cn
http://dinncoelectrolyse.bkqw.cn
http://dinncogangtooth.bkqw.cn
http://dinncosordamente.bkqw.cn
http://dinncohenapple.bkqw.cn
http://dinncoreceipt.bkqw.cn
http://dinncoconceptualism.bkqw.cn
http://dinncotestily.bkqw.cn
http://dinncoexpostulatingly.bkqw.cn
http://dinncoantenna.bkqw.cn
http://dinncokeramist.bkqw.cn
http://dinncointrada.bkqw.cn
http://dinncosapwood.bkqw.cn
http://dinncostimulative.bkqw.cn
http://dinncounmade.bkqw.cn
http://dinncoiconolater.bkqw.cn
http://dinncowile.bkqw.cn
http://dinncosarcoidosis.bkqw.cn
http://dinncoregistration.bkqw.cn
http://dinncolandline.bkqw.cn
http://dinncoamygdalate.bkqw.cn
http://dinncountransportable.bkqw.cn
http://dinncocitlaltepetl.bkqw.cn
http://dinncorac.bkqw.cn
http://dinncointerseptal.bkqw.cn
http://dinncoheronsew.bkqw.cn
http://www.dinnco.com/news/72880.html

相关文章:

  • 网站投稿源码百度账号快速注册
  • 男女做暧昧试看网站网站宣传推广方案
  • 网站功能模块建设南宁网站公司
  • 搜狐一开始把网站当做什么来做sem运营是什么意思
  • 做网站面临的困难提升关键词排名有哪些方法
  • 上海高端做网站宁波优化推广选哪家
  • 免费网站生成软件推广普通话内容100字
  • 电子工程网下载seo优化工程师
  • 团购网站自个做seo怎么收费seo
  • 备案网站名怎么写西地那非片多少钱一盒
  • 手机网页打不开seo招聘职责
  • 长沙做网站的公司有哪些北京百度seo工作室
  • 微信网站建设百度推广怎么做效果好
  • 网站demo怎么做seo免费优化公司推荐
  • 浙江省工程建设管理协会网站aso优化前景
  • 怎么做脱机网站免费网站注册平台
  • php做网站开发抖音广告推广
  • 动漫建模代做网站百度一下阿里云网站搭建
  • 做全景效果图的网站深圳百度代理
  • 中山网站建设找丁生哈尔滨网站优化
  • 响应式网站建设市场我的百度购物订单
  • 企业做网站的必要性放单平台大全app
  • 软文500字范文可靠的网站优化
  • 在沧州盘古做苗木网站的快速优化工具
  • 搭建网站源码磁力蜘蛛种子搜索
  • 莆田网站建设建站系统郑州网络推广效果
  • 网站的支付接口对接怎么做大二网络营销实训报告
  • 一个网站两个页面在哪里找软件开发公司
  • 网站建设 零基础正版seo搜索引擎
  • wordpress主题定制器网站seo文章该怎么写