首页 > 数据库技术 > 详细

pymysql中的参数及方法

时间:2018-09-04 23:03:05      阅读:259      评论:0      收藏:0      [点我收藏+]

1、connect(参数)
  Connection = Connect(*args, **kwargs)
  Establish a connection to the MySQL database. Accepts several
  arguments:

  host: Host where the database server is located
  user: Username to log in as
  password: Password to use.
  database: Database to use, None to not use a particular one.
  port: MySQL port to use, default is usually OK. (default: 3306)
  bind_address: When the client has multiple network interfaces, specify
  the interface from which to connect to the host. Argument can be
  a hostname or an IP address.
  unix_socket: Optionally, you can use a unix socket rather than TCP/IP.
  charset: Charset you want to use.
  sql_mode: Default SQL_MODE to use.
  read_default_file:
  Specifies my.cnf file to read these parameters from under the [client] section.

2、db(数据库连接对象)的方法
  1、db.close():断开连接
  2、db.commit():提交到数据库执行
  3、db.cursor():创建游标
  4、db.rollback():回滚
3、cursor游标对象的方法
  1、execute(SQL命令):执行SQL命令
  2、close():关闭游标对象
  3、fetchone():获取查询结果的第1条数据
  4、fetchmany(n):获取n条数据
  5、fetchall():获取所有的数据
  ##fetchmany(n)和fetchall()得到的结果一定是一个大元组套着小元组((),(),()...)

pymysql中的参数及方法

原文:https://www.cnblogs.com/zengsf/p/9589015.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!