首页 map[addtime:<nil> column:0 data:{"status":0,"msg":"","data":{"data":{"banner":[{"image":"/assets/upload/2024/10/09/8321b9b943cd4f57fe891334012bebb1.png","t1":"感恩有你,未来可期","t2":"","t3":"/p/2802"}],"name1":"新闻资讯"}}} data2:<nil> description:16年IT服务经验-全国服务电话:400-017-5181 featured: id:1 illustrate:新闻资讯 keywords:同创双子公司新闻, 同创双子,同创双子怎么样,同创双子公司,成都同创双子,北京同创双子,同创双子最新新闻 name:新闻资讯 orders:1 state:true tag:<nil> templateslist:{ "controls": [ { "name": "data.name1", "label": "简单标题", "type": "input-text" }, { "type": "combo", "name": "data.banner", "label": "轮播", "multiple": true, "draggable": true, "items": [ { "name": "t1", "label": "标题", "type": "input-text" }, { "name": "t2", "label": "时间", "type": "input-text" }, { "name": "t3", "label": "连接", "type": "input-text" }, { "type": "input-image", "name": "image", "label": "配图", "receiver": "./api/upload?rich=2" } ] } ] } templatespage:{ "controls": [ { "label": "推荐等级", "type": "select", "name": "featured", "options": [ { "label": "不推荐", "value": 0 }, { "label": "首页推荐", "value": 1001 } ] }, { "type": "group", "body": [ { "name": "data.listimg", "label": "列表图片", "receiver": "./api/upload?rich=2", "type": "input-image" }, { "name": "data.img", "label": "首页图片", "receiver": "./api/upload?rich=2", "type": "input-image" } ] }, { "type": "input-rich-text", "name": "data.body", "label": "文章内容1", "receiver": "post:./api/upload?rich=1" } ] } title:新闻资讯-同创双子(北京)信息技术股份有限公司 tmpllist:list tmplpage:page url:news] > 新闻资讯 map[addtime:<nil> column:1 data:{"status":0,"msg":"","data":{"data":{"banner":[{"image":"/assets/upload/2023/12/13/3e1643bd17c60956f27ddf735eb3048d.png","t1":"桌面运维是什么?外包好还是自招好","t3":"https://www.itgemini.net/p/2613"},{"image":"/assets/upload/2023/12/13/d52a5f367538356cbcbfbbf727a5e0a7.png","t1":"什么是系统集成?同创双子可以做哪些系统集成服务","t3":"https://www.itgemini.net/p/2611"}],"name1":"干货分享"}}} data2:<nil> description:16年IT服务经验-全国服务电话:400-017-5181 featured: id:3 illustrate:干货分享 keywords:同创双子公司新闻, 同创双,同创双子公司,成都同创双子,北京同创双子,同创双子最新新闻,电脑卡顿,电脑故障,网络故障 name:干货分享 orders:1 state:true tag:<nil> templateslist:{ "controls": [ { "name": "data.name1", "label": "简单标题", "type": "input-text" }, { "type": "combo", "name": "data.banner", "label": "轮播", "multiple": true, "draggable": true, "items": [ { "name": "t1", "label": "标题", "type": "input-text" }, { "name": "t2", "label": "时间", "type": "input-text" }, { "name": "t3", "label": "连接", "type": "input-text" }, { "type": "input-image", "name": "image", "label": "配图", "receiver": "./api/upload?rich=2" } ] } ] } templatespage:{ "controls": [ { "label": "推荐等级", "type": "select", "name": "featured", "options": [ { "label": "不推荐", "value": 0 }, { "label": "首页推荐", "value": 1001 } ] }, { "type": "group", "body": [ { "name": "data.listimg", "label": "列表图片", "receiver": "./api/upload?rich=2", "type": "input-image" }, { "name": "data.img", "label": "首页图片", "receiver": "./api/upload?rich=2", "type": "input-image" } ] }, { "type": "input-rich-text", "name": "data.body", "label": "文章内容", "receiver": "post:./api/upload?rich=1" } ] } title:干货分享-IT技巧-同创双子(北京)信息技术股份有限公司 tmpllist:list tmplpage:page url:share] > 干货分享
PyMySQL相关方法介绍

发布日期:2018/10/17 08:00:00

  "pymysql.Connect()" 参数详解

  host(str): MySQL服务器?地址

  port(int): MySQL服务器?端?口号

  user(str): ?用户名

  passwd(str): 密码

  db(str): 数据库名称

  charset(str): 连接编码

  "connection" 对象?支持的?方法

  cursor() 使?用该连接创建并返回游标

  commit() 提交当前事务

  rollback() 回滚当前事务

  close() 关闭连接

  "cursor" 对象?支持的?方法

  execute(op) 执?行行?一个数据库的查询命令

  fetchone() 取得结果集的下?一?行行

  fetchmany(size) 获取结果集的下?几?行行

  fetchall() 获取结果集中的所有?行行

  rowcount() 返回数据条数或影响?行行数

  close() 关闭游标对象

  连接数据库

  第?一次连接数据库

  配置connect

  import pymysql

  db_con = pymysql.connect(

  host = '127.0.0.1',

  port = 3306,

  user = 'root',

  password = 'Redhot',

  db = 'luffly',

  charset = 'utf8'

  )

  connect(*args,**kwargs),中没有固定的位置参数,调取 connect() 会初始

  化?一个 Connection 类,所以必须指定位置参数,否则会连接失败。

  创建游标,输?入?一条指令,并获取返回数据。

  cur = db_con.cursor() # 创建连接游标

  cur.execute('select version()') # 输?入指令

  return_data = cur.fetone() # 获取?一条返回数据

  print("The DB Version is %s" % return_data)

  结果如下:

  The DB Version is ('10.3.9-MariaDB',)

  cursor.fetone() 会返回?一组元组数据,每?一?行行数据为?一个元素,所以优化?一下

  返回结果。

  return_info = return_data[0]

  print("The DB Version is %s" % return_info)

  结果如下:

  The DB Version is 10.3.9-MariaDB


同创双子为企业保驾护航

专注数字化方案建设,推动智慧企业生态圈的升级发展