• pymysql中的参数及方法


    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()得到的结果一定是一个大元组套着小元组((),(),()...)

  • 相关阅读:
    2019/10/9 CSP-S 模拟测
    简单的面向对象
    魔术变量
    函数
    全局变量
    超级全局变量
    for循环
    while循环
    php数组排序
    python打造XslGenerator
  • 原文地址:https://www.cnblogs.com/zengsf/p/9589015.html
Copyright © 2020-2023  润新知