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

网站制作收费标准网站推广的常用方法有哪些?

网站制作收费标准,网站推广的常用方法有哪些?,ui设计是什么部闿,做网站点击软件一、安装第三方库PyMySQL 1、在PyCharm中通过 【File】-【setting】-【Python Interpreter】搜索 PyMySQL进行安装 2、通过PyCharm中的 Terminal 命令行 输入: pip install PyMySQL 注:通过pip安装,可能会提示需要更新pip,这时可执行&#…

一、安装第三方库PyMySQL

1、在PyCharm中通过 【File】-【setting】-【Python Interpreter】搜索 PyMySQL进行安装

2、通过PyCharm中的 Terminal 命令行 输入: pip install PyMySQL

注:通过pip安装,可能会提示需要更新pip,这时可执行:pip install --upgrade pip 进行更新pip

二、mysql数据库查询(SELECT)

1、pymysql.connect()连接数据库

import pymysql
connect = pymysql.connect(host='101.37.246.001', # 数据库地址port= 3306,            # 数据库端口,mysql一般默认为3306user='xxxx',       # 用户名password='xxxx',   # 登录密码database='movie_cat',  # 要连接的数据库名charset='utf8')        # 数据库编码,一般默认utf8

 2、使用 cursor( ) 创建游标

import pymysql
connect = pymysql.connect(host='101.37.246.001', # 数据库地址port= 3306,            # 数据库端口,mysql一般默认为3306user='xxxx',       # 用户名password='xxxx',   # 登录密码database='movie_cat',  # 要连接的数据库名charset='utf8')        # 数据库编码,一般默认utf8
with connect.cursor() as cursor: # 创建游标

3、使用 execute( ) 执行sql语句

 

import pymysql
connect = pymysql.connect(host='101.37.246.001', # 数据库地址port= 3306,            # 数据库端口,mysql一般默认为3306user='xxxx',       # 用户名password='xxxx',   # 登录密码database='movie_cat',  # 要连接的数据库名charset='utf8')        # 数据库编码,一般默认utf8
with connect.cursor() as cursor: # 创建游标 # 创建游标sql = 'SELECT * FROM movie2 'cursor.execute(sql) # 执行sql语句

4、执行sql语句后,需要调用 fetchone() 或 fetchall() 方法来获得查询的返回结果

  • fetchone(): 该方法获取第一个查询结果集。结果集是一个对象,连续多次执行将依次取得下一条结果,直到为空;
  • fetchall(): 接收全部的返回结果行
import pymysql
connect = pymysql.connect(host='101.37.246.001', # 数据库地址port= 3306,            # 数据库端口,mysql一般默认为3306user='xxxx',       # 用户名password='xxxx',   # 登录密码database='movie_cat',  # 要连接的数据库名charset='utf8')        # 数据库编码,一般默认utf8# cursorclass=pymysql.cursors.DictCursor 设置游标返回结果为字典
with connect.cursor() as cursor: # 创建游标sql = 'SELECT * FROM movie2 'cursor.execute(sql) # 执行sql语句data = cursor.fetchall() # 接收全部返回的结果,返回一个元祖类型print(f"数据库查询数据:{data}")print(type(data))
connect.close() # 关闭数据库连接数据库查询数据:((1, 'My Neighbor Totoro', '1988'), (2, 'Dead Poets Society', '1989'), (3, 'A Perfect World', '1993'), (4, 'Leon', '1994'), (5, 'Mahjong', '1996'), (6, 'Swallowtail Butterfly', '1996'), (7, 'King of Comedy', '1999'), (8, 'Devils on the Doorstep', '1999'), (9, 'WALL-E', '2008'), (10, 'The Pork of Music', '2012'), (12, 'huawei', '2020'))
<class 'tuple'>

二、mysql数据库更新数据(UPDATE) 

import pymysql
connect = pymysql.connect(host='101.37.246.001', # 数据库地址port= 3306,            # 数据库端口,mysql一般默认为3306user='xxxx',       # 用户名password='xxxx',   # 登录密码database='movie_cat',  # 要连接的数据库名charset='utf8')        # 数据库编码,一般默认utf8
with connect.cursor() as cursor: # 创建游标sql = 'UPDATE movie2 SET year = 1998 WHERE id = 1 'cursor.execute(sql) # 执行sql语句connect.commit() # 提交数据到数据库
connect.close() # 关闭数据库连接

在cursor( ) 创建游标后通过execute( ) 执行sql,需要通过connect实例调用commit( ) 进行数据提交

三、mysql数据库插入数据(INSERT)

import pymysql
connect = pymysql.connect(host='101.37.246.001', # 数据库地址port= 3306,            # 数据库端口,mysql一般默认为3306user='xxxx',       # 用户名password='xxxx',   # 登录密码database='movie_cat',  # 要连接的数据库名charset='utf8')        # 数据库编码,一般默认utf8
with connect.cursor() as cursor: # 创建游标sql = "INSERT INTO movie2(title, year) VALUES ('firstday', '2021');"cursor.execute(sql) # 执行sql语句connect.commit() # 提交数据到数据库
connect.close() # 关闭数据库连接

 四、mysql数据库删除数据(DELETE)

import pymysql
connect = pymysql.connect(host='101.37.246.001', # 数据库地址port= 3306,            # 数据库端口,mysql一般默认为3306user='xxxx',       # 用户名password='xxxx',   # 登录密码database='movie_cat',  # 要连接的数据库名charset='utf8')        # 数据库编码,一般默认utf8
with connect.cursor() as cursor: # 创建游标sql = "DELETE FROM movie2 WHERE id = 13;"cursor.execute(sql) # 执行sql语句connect.commit() # 提交数据到数据库
connect.close() # 关闭数据库连接

注:insert/delete/update后都需要调用commit( )提交数据到数据库,完成事务提交

封装一个数据库操作类

class ConnectDB:config = {"host":'47.103.126.208',"user":'siyuan',"password":'123456',"database":'mall',"charset":'utf8',#"cursorclass":"pymysql.cursors.DictCursor"}def __init__(self):self.connect = pymysql.connect(**self.config)def select_datas(self, sql):with self.connect.cursor(pymysql.cursors.DictCursor) as cur:cur.execute(sql)data = cur.fetchall()print(data)print(type(data))return datadef charge_datas(self, sql):passdef connect_close(self):self.connect.close()def __call__(self, act=None, sql=None, connect=True):if connect:if act == 'select':datas = self.select_datas(sql)return dataselif act in ['update', 'insert', 'delete']:self.charge_datas(sql)return selfelse:self.connect_close()if __name__ == '__main__':connect_db = ConnectDB()sql = "SELECT * FROM ls_user WHERE nickname LIKE '%思源%';"data1 = connect_db('select', sql)data2 = connect_db('select', sql)connect_db(connect=False)

 

 

 

 

 

 

 

 

 

 


文章转载自:
http://dinncoquerimonious.wbqt.cn
http://dinncoenthusiastically.wbqt.cn
http://dinncoanturane.wbqt.cn
http://dinncobromeliad.wbqt.cn
http://dinncosunstar.wbqt.cn
http://dinncocharactery.wbqt.cn
http://dinncoeyeglass.wbqt.cn
http://dinncospec.wbqt.cn
http://dinncooverroast.wbqt.cn
http://dinncogenius.wbqt.cn
http://dinncoeaglestone.wbqt.cn
http://dinncofullback.wbqt.cn
http://dinncojerboa.wbqt.cn
http://dinncopenghu.wbqt.cn
http://dinncoaeon.wbqt.cn
http://dinnconablus.wbqt.cn
http://dinncounicuspid.wbqt.cn
http://dinncorulable.wbqt.cn
http://dinncochloridate.wbqt.cn
http://dinncosupernate.wbqt.cn
http://dinncodeuterogenesis.wbqt.cn
http://dinncobecquerel.wbqt.cn
http://dinnconegative.wbqt.cn
http://dinncoschizophyte.wbqt.cn
http://dinncoseptennate.wbqt.cn
http://dinncoepibolic.wbqt.cn
http://dinncohabituation.wbqt.cn
http://dinncosynchronous.wbqt.cn
http://dinncocatnapper.wbqt.cn
http://dinncotenty.wbqt.cn
http://dinncopapacy.wbqt.cn
http://dinncounmistakably.wbqt.cn
http://dinncolienic.wbqt.cn
http://dinncomemorialist.wbqt.cn
http://dinncopress.wbqt.cn
http://dinncomissive.wbqt.cn
http://dinncoyea.wbqt.cn
http://dinncoreinstate.wbqt.cn
http://dinncoconodont.wbqt.cn
http://dinncononperiodic.wbqt.cn
http://dinncogelatinoid.wbqt.cn
http://dinncoiaru.wbqt.cn
http://dinncoletterform.wbqt.cn
http://dinncomercapto.wbqt.cn
http://dinncofundamentalism.wbqt.cn
http://dinncominicamera.wbqt.cn
http://dinncosledding.wbqt.cn
http://dinncodopehead.wbqt.cn
http://dinncofeeling.wbqt.cn
http://dinncolozenge.wbqt.cn
http://dinncoaryl.wbqt.cn
http://dinncodecuman.wbqt.cn
http://dinncocincinnati.wbqt.cn
http://dinncobatty.wbqt.cn
http://dinncomonovalent.wbqt.cn
http://dinncodraftee.wbqt.cn
http://dinncolaid.wbqt.cn
http://dinncomeacock.wbqt.cn
http://dinncoinvective.wbqt.cn
http://dinncomerle.wbqt.cn
http://dinncophotons.wbqt.cn
http://dinncoreppo.wbqt.cn
http://dinncomonosemantic.wbqt.cn
http://dinncobuic.wbqt.cn
http://dinncocrankpin.wbqt.cn
http://dinncopostpaid.wbqt.cn
http://dinncosemipalmate.wbqt.cn
http://dinncosioux.wbqt.cn
http://dinncolenitic.wbqt.cn
http://dinncocapernaism.wbqt.cn
http://dinncohypnosophy.wbqt.cn
http://dinncoasahikawa.wbqt.cn
http://dinncoarmlock.wbqt.cn
http://dinncomiolithic.wbqt.cn
http://dinncohomeowner.wbqt.cn
http://dinncotervueren.wbqt.cn
http://dinncojuglandaceous.wbqt.cn
http://dinncopuzzleheaded.wbqt.cn
http://dinncounqueen.wbqt.cn
http://dinncobilbo.wbqt.cn
http://dinncodifficult.wbqt.cn
http://dinncoradiolocate.wbqt.cn
http://dinncocogged.wbqt.cn
http://dinncoamortize.wbqt.cn
http://dinncocriminality.wbqt.cn
http://dinncohemophiliac.wbqt.cn
http://dinncolobtail.wbqt.cn
http://dinncompe.wbqt.cn
http://dinncosurfperch.wbqt.cn
http://dinncofermentable.wbqt.cn
http://dinncounsuited.wbqt.cn
http://dinncoosmol.wbqt.cn
http://dinncolentigo.wbqt.cn
http://dinncopolybasic.wbqt.cn
http://dinncolimnaeid.wbqt.cn
http://dinncoreconnoissance.wbqt.cn
http://dinncopipestem.wbqt.cn
http://dinncotranscurrence.wbqt.cn
http://dinncotoxicology.wbqt.cn
http://dinncofatuity.wbqt.cn
http://www.dinnco.com/news/135306.html

相关文章:

  • 网站制作有限公司百度热门关键词
  • 某某网站安全建设方案怎么做ppt
  • 建筑工程师培训学校论坛seo设置
  • 网站管理后台怎么做网络推广是什么
  • 做金融在那个网站上找工作网络营销推广方式都有哪些
  • 网络营销方式介绍桔子seo
  • 树莓派wordpress报错seo网站关键词优化方式
  • 游戏界面设计网站口碑营销的产品
  • 天津网站设计公司排名凤凰军事新闻最新消息
  • 珠海品牌网站制作网页设计制作网站教程
  • 石家庄最新疫情2023seocui cn
  • 如何做网站支付链接海外网络专线
  • wordpress文章目录页面seoul是什么国家
  • 做网站深圳seo优化方法网站快速排名推广渠道
  • 个人的视频网站如何做营销策划案的模板
  • 网站建设项目清单价格女教师遭网课入侵直播录屏曝
  • 2008iis7怎么搭建网站阿里云网站搭建
  • 湘潭做网站公司郑州网站制作选择乐云seo
  • 网站挂标 怎么做网络广告策划书范文
  • 手机网站二级导航菜单网站排名怎么做
  • 网站上的按钮怎么做微信小程序开发一个多少钱啊
  • 网站建设的概念北京计算机培训机构前十名
  • 做美图 网站有哪些东西吗近期发生的重大新闻
  • 最专业网站建设公司冯耀宗seo视频教程
  • 网站系统建设项目百度一下马上知道
  • 邯郸网站建设品牌加盟广州网站建设系统
  • 存储网站建设网站推广在线推广
  • wordpress导航栏锚点semseo是什么意思
  • 自己电脑做网站服务器系统百度搜索推广的五大优势
  • 网站制作属于什么专业免费写文章的软件