当前位置:首页>python>Python3 PyMySQL驱动操作数据库全面学习教程

Python3 PyMySQL驱动操作数据库全面学习教程

  • 2026-02-07 12:47:17
Python3 PyMySQL驱动操作数据库全面学习教程

大家好,今天我们来聊聊Python操作MySQL数据库这个话题。别看这玩意儿简单,但新手朋友经常在这上面摔跟头。

今天我就手把手教你,从零开始学习使用PyMySQL操作MySQL数据库,让你一次掌握,从此告别"Python连接数据库总出错"的尴尬!

为什么选择PyMySQL?

在开始学习之前,先聊聊为什么我们要选择PyMySQL:

  1. 纯Python实现:完全用Python编写,不需要额外的C库依赖
  2. 简单易用:API设计直观,学习成本低
  3. 兼容性好:支持Python 3.6+和MySQL 5.6+
  4. 社区活跃:GitHub上star众多,文档完善
  5. 功能完整:支持所有MySQL特性,包括SSL连接

安装PyMySQL

环境要求

在安装之前,确保你已经:

  • 安装了Python 3.6或更高版本
  • 安装了MySQL服务器并正常运行

安装步骤

# 使用pip安装PyMySQLpip install PyMySQL# 验证安装是否成功python -c "import pymysql; print(pymysql.__version__)"

如果看到版本号输出,说明安装成功。

建立数据库连接

基本连接方式

import pymysql# 建立数据库连接connection = pymysql.connect(    host='localhost',        # 数据库主机地址    port=3306,              # 数据库端口    user='root',            # 用户名    password='your_password'# 密码    database='test_db',     # 数据库名    charset='utf8mb4'# 字符集)# 关闭连接connection.close()

连接参数详解

import pymysql# 完整的连接参数配置connection = pymysql.connect(    host='localhost',           # 主机地址    port=3306,                 # 端口号    user='your_username',      # 用户名    password='your_password',  # 密码    database='your_database',  # 数据库名    charset='utf8mb4',         # 字符集    autocommit=False,          # 是否自动提交    connect_timeout=10,        # 连接超时时间    read_timeout=10,           # 读取超时时间    write_timeout=10,          # 写入超时时间    cursorclass=pymysql.cursors.DictCursor  # 游标类型)

使用上下文管理器

推荐使用with语句管理连接,确保连接正确关闭:

import pymysql# 使用with语句自动管理连接with pymysql.connect(    host='localhost',    user='root',    password='your_password',    database='test_db',    charset='utf8mb4'as connection:# 在这里执行数据库操作pass# 连接会自动关闭

创建游标对象

游标对象用于执行SQL语句和获取结果:

import pymysql# 建立连接connection = pymysql.connect(    host='localhost',    user='root',    password='your_password',    database='test_db',    charset='utf8mb4')# 创建游标对象cursor = connection.cursor()# 执行SQL语句cursor.execute("SELECT VERSION()")# 获取结果result = cursor.fetchone()print(f"MySQL版本: {result[0]}")# 关闭游标和连接cursor.close()connection.close()

不同类型的游标

import pymysql.cursors# 默认游标 - 返回元组with pymysql.connect(...) as connection:    cursor = connection.cursor()    cursor.execute("SELECT * FROM users")    result = cursor.fetchall()  # ((1, 'Alice', 25), (2, 'Bob', 30))# 字典游标 - 返回字典with pymysql.connect(    cursorclass=pymysql.cursors.DictCursoras connection:    cursor = connection.cursor()    cursor.execute("SELECT * FROM users")    result = cursor.fetchall()  # [{'id': 1, 'name': 'Alice', 'age': 25}, ...]# 字典游标的优势是可以通过键名访问字段print(result[0]['name'])  # 输出: Alice

数据库基本操作

创建数据库和表

import pymysql# 连接MySQL服务器(不指定数据库)connection = pymysql.connect(    host='localhost',    user='root',    password='your_password',    charset='utf8mb4')try:with connection.cursor() as cursor:# 创建数据库        cursor.execute("CREATE DATABASE IF NOT EXISTS myapp")# 选择数据库        cursor.execute("USE myapp")# 创建用户表        create_table_sql = """        CREATE TABLE IF NOT EXISTS users (            id INT AUTO_INCREMENT PRIMARY KEY,            username VARCHAR(50) NOT NULL UNIQUE,            email VARCHAR(100) NOT NULL UNIQUE,            age INT,            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4        """        cursor.execute(create_table_sql)# 提交事务    connection.commit()finally:    connection.close()

插入数据

import pymysqlfrom datetime import datetime# 插入单条数据definsert_user(username, email, age):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4'    )try:with connection.cursor() as cursor:# 使用参数化查询防止SQL注入            sql = "INSERT INTO users (username, email, age) VALUES (%s, %s, %s)"            cursor.execute(sql, (username, email, age))# 提交事务        connection.commit()        print("用户插入成功")except Exception as e:# 回滚事务        connection.rollback()        print(f"插入失败: {e}")finally:        connection.close()# 调用函数insert_user("张三""zhangsan@example.com"25)

批量插入数据

import pymysql# 批量插入数据defbatch_insert_users(users_data):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4'    )try:with connection.cursor() as cursor:            sql = "INSERT INTO users (username, email, age) VALUES (%s, %s, %s)"# executemany用于批量插入            cursor.executemany(sql, users_data)        connection.commit()        print(f"成功插入{len(users_data)}条用户数据")except Exception as e:        connection.rollback()        print(f"批量插入失败: {e}")finally:        connection.close()# 准备批量数据users = [    ("李四""lisi@example.com"28),    ("王五""wangwu@example.com"32),    ("赵六""zhaoliu@example.com"29)]# 执行批量插入batch_insert_users(users)

查询数据

import pymysql# 查询单条数据defget_user_by_id(user_id):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4',        cursorclass=pymysql.cursors.DictCursor    )try:with connection.cursor() as cursor:            sql = "SELECT * FROM users WHERE id = %s"            cursor.execute(sql, (user_id,))            result = cursor.fetchone()return resultfinally:        connection.close()# 查询多条数据defget_users_by_age(min_age):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4',        cursorclass=pymysql.cursors.DictCursor    )try:with connection.cursor() as cursor:            sql = "SELECT * FROM users WHERE age >= %s ORDER BY age"            cursor.execute(sql, (min_age,))            results = cursor.fetchall()return resultsfinally:        connection.close()# 使用示例user = get_user_by_id(1)if user:    print(f"用户信息: {user}")users = get_users_by_age(25)print("年龄大于等于25的用户:")for user in users:    print(f"  {user['username']}{user['age']}岁")

更新数据

import pymysql# 更新用户信息defupdate_user(user_id, username=None, email=None, age=None):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4'    )try:with connection.cursor() as cursor:# 动态构建更新语句            updates = []            params = []if username:                updates.append("username = %s")                params.append(username)if email:                updates.append("email = %s")                params.append(email)if age isnotNone:                updates.append("age = %s")                params.append(age)ifnot updates:                print("没有需要更新的字段")return# 添加WHERE条件参数            params.append(user_id)            sql = f"UPDATE users SET {', '.join(updates)} WHERE id = %s"            cursor.execute(sql, params)        connection.commit()        print("用户信息更新成功")except Exception as e:        connection.rollback()        print(f"更新失败: {e}")finally:        connection.close()# 使用示例update_user(1, age=26, email="newemail@example.com")

删除数据

import pymysql# 删除用户defdelete_user(user_id):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4'    )try:with connection.cursor() as cursor:            sql = "DELETE FROM users WHERE id = %s"            cursor.execute(sql, (user_id,))        connection.commit()        print("用户删除成功")except Exception as e:        connection.rollback()        print(f"删除失败: {e}")finally:        connection.close()# 使用示例delete_user(1)

事务处理

基本事务操作

import pymysql# 事务示例:转账操作deftransfer_money(from_user_id, to_user_id, amount):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4'    )try:with connection.cursor() as cursor:# 开始事务            connection.begin()# 检查转出用户余额            cursor.execute("SELECT balance FROM accounts WHERE user_id = %s", (from_user_id,))            from_balance = cursor.fetchone()ifnot from_balance or from_balance[0] < amount:raise Exception("余额不足")# 扣除转出用户余额            cursor.execute("UPDATE accounts SET balance = balance - %s WHERE user_id = %s"                          (amount, from_user_id))# 增加转入用户余额            cursor.execute("UPDATE accounts SET balance = balance + %s WHERE user_id = %s"                          (amount, to_user_id))# 记录转账日志            cursor.execute("""                INSERT INTO transfer_logs (from_user_id, to_user_id, amount, transfer_time)                 VALUES (%s, %s, %s, NOW())            """, (from_user_id, to_user_id, amount))# 提交事务            connection.commit()            print("转账成功")except Exception as e:# 回滚事务        connection.rollback()        print(f"转账失败: {e}")finally:        connection.close()# 使用示例transfer_money(12100.00)

高级查询技巧

分页查询

import pymysql# 分页查询用户列表defget_users_paginated(page, page_size):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4',        cursorclass=pymysql.cursors.DictCursor    )try:with connection.cursor() as cursor:            offset = (page - 1) * page_size            sql = "SELECT * FROM users LIMIT %s OFFSET %s"            cursor.execute(sql, (page_size, offset))            users = cursor.fetchall()# 获取总记录数            cursor.execute("SELECT COUNT(*) as total FROM users")            total = cursor.fetchone()['total']return {'users': users,'total': total,'page': page,'page_size': page_size,'total_pages': (total + page_size - 1) // page_size            }finally:        connection.close()# 使用示例result = get_users_paginated(110)print(f"第{result['page']}页,共{result['total_pages']}页")for user in result['users']:    print(f"  {user['username']}")

条件查询

import pymysql# 复杂条件查询defsearch_users(username=None, min_age=None, max_age=None, email_domain=None):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4',        cursorclass=pymysql.cursors.DictCursor    )try:with connection.cursor() as cursor:# 动态构建查询条件            conditions = []            params = []if username:                conditions.append("username LIKE %s")                params.append(f"%{username}%")if min_age isnotNone:                conditions.append("age >= %s")                params.append(min_age)if max_age isnotNone:                conditions.append("age <= %s")                params.append(max_age)if email_domain:                conditions.append("email LIKE %s")                params.append(f"%@{email_domain}")# 构建SQL语句if conditions:                sql = f"SELECT * FROM users WHERE {' AND '.join(conditions)} ORDER BY created_at DESC"else:                sql = "SELECT * FROM users ORDER BY created_at DESC"            cursor.execute(sql, params)            results = cursor.fetchall()return resultsfinally:        connection.close()# 使用示例users = search_users(username="张", min_age=20, max_age=30)print("搜索结果:")for user in users:    print(f"  {user['username']}{user['age']}岁, {user['email']}")

错误处理和最佳实践

异常处理

import pymysqlfrom pymysql import IntegrityError, OperationalError# 完整的错误处理示例defsafe_database_operation():    connection = Nonetry:# 建立连接        connection = pymysql.connect(            host='localhost',            user='root',            password='your_password',            database='myapp',            charset='utf8mb4',            autocommit=False,            connect_timeout=5        )with connection.cursor() as cursor:# 执行数据库操作            sql = "INSERT INTO users (username, email, age) VALUES (%s, %s, %s)"            cursor.execute(sql, ("test_user""test@example.com"25))# 提交事务            connection.commit()            print("操作成功")except IntegrityError as e:# 处理数据完整性错误(如唯一约束冲突)if connection:            connection.rollback()        print(f"数据完整性错误: {e}")except OperationalError as e:# 处理操作错误(如连接失败)        print(f"数据库操作错误: {e}")except Exception as e:# 处理其他异常if connection:            connection.rollback()        print(f"未知错误: {e}")finally:# 确保连接关闭if connection:            connection.close()# 调用函数safe_database_operation()

连接池使用

import pymysqlfrom dbutils.pooled_db import PooledDB# 创建连接池pool = PooledDB(    creator=pymysql,    host='localhost',    port=3306,    user='root',    password='your_password',    database='myapp',    charset='utf8mb4',    maxconnections=20,  # 最大连接数    mincached=2,        # 最小缓存连接数    maxcached=5,        # 最大缓存连接数    maxshared=3,        # 最大共享连接数    blocking=True,      # 连接池满时是否阻塞等待    maxusage=None,      # 单个连接最大复用次数    setsession=[],      # 开始会话前执行的命令列表    ping=0# ping MySQL服务端)# 使用连接池defget_user_with_pool(user_id):# 从连接池获取连接    connection = pool.connection()try:with connection.cursor() as cursor:            cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))            result = cursor.fetchone()return resultfinally:# 关闭连接(归还到连接池)        connection.close()# 使用示例user = get_user_with_pool(1)if user:    print(f"用户信息: {user}")

安全最佳实践

防止SQL注入

import pymysql# 正确的做法:使用参数化查询defsafe_query(username):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4'    )try:with connection.cursor() as cursor:# 使用参数化查询,防止SQL注入            sql = "SELECT * FROM users WHERE username = %s"            cursor.execute(sql, (username,))            result = cursor.fetchall()return resultfinally:        connection.close()# 错误的做法:字符串拼接(容易被SQL注入)defunsafe_query(username):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4'    )try:with connection.cursor() as cursor:# 危险!容易被SQL注入攻击            sql = f"SELECT * FROM users WHERE username = '{username}'"            cursor.execute(sql)  # 不要这样做!            result = cursor.fetchall()return resultfinally:        connection.close()# 安全查询示例users = safe_query("admin'; DROP TABLE users; --")print(users)  # 只会查找用户名为 "admin'; DROP TABLE users; --" 的用户

密码安全管理

import pymysqlimport osfrom dotenv import load_dotenv# 加载环境变量load_dotenv()# 从环境变量获取数据库配置defget_db_config():return {'host': os.getenv('DB_HOST''localhost'),'port': int(os.getenv('DB_PORT'3306)),'user': os.getenv('DB_USER''root'),'password': os.getenv('DB_PASSWORD'),'database': os.getenv('DB_NAME''myapp'),'charset''utf8mb4'    }# 使用环境变量连接数据库defconnect_with_env():    config = get_db_config()    connection = pymysql.connect(**config)return connection# 创建.env文件示例:"""DB_HOST=localhostDB_PORT=3306DB_USER=myuserDB_PASSWORD=mypasswordDB_NAME=myapp"""

性能优化技巧

批量操作优化

import pymysql# 高效的批量插入defefficient_batch_insert(data_list):    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4'    )try:with connection.cursor() as cursor:# 使用事务和批量插入提高性能            connection.begin()            sql = "INSERT INTO users (username, email, age) VALUES (%s, %s, %s)"            cursor.executemany(sql, data_list)            connection.commit()            print(f"批量插入{len(data_list)}条记录成功")except Exception as e:        connection.rollback()        print(f"批量插入失败: {e}")finally:        connection.close()# 准备大量数据进行测试large_data = [    (f"user_{i}"f"user_{i}@example.com"20 + (i % 50))for i in range(1000)]# 执行批量插入efficient_batch_insert(large_data)

查询优化

import pymysql# 使用索引优化查询defoptimized_query():    connection = pymysql.connect(        host='localhost',        user='root',        password='your_password',        database='myapp',        charset='utf8mb4',        cursorclass=pymysql.cursors.DictCursor    )try:with connection.cursor() as cursor:# 为经常查询的字段创建索引            cursor.execute("CREATE INDEX idx_username ON users(username)")            cursor.execute("CREATE INDEX idx_email ON users(email)")            cursor.execute("CREATE INDEX idx_age ON users(age)")# 使用EXPLAIN分析查询性能            cursor.execute("EXPLAIN SELECT * FROM users WHERE username = 'admin'")            explain_result = cursor.fetchall()            print("查询执行计划:")for row in explain_result:                print(row)finally:        connection.close()

结语

到这里,PyMySQL操作数据库的全面学习就完成了!从安装配置、基本操作到高级技巧,每一步都详细讲解了。

记住几个关键点:

  1. 安全第一:始终使用参数化查询防止SQL注入
  2. 连接管理:合理使用连接池提高性能
  3. 事务处理:正确使用事务保证数据一致性
  4. 错误处理:完善的异常处理机制
  5. 性能优化:批量操作和索引优化

PyMySQL是Python操作MySQL数据库的强大工具,掌握它对于后端开发人员来说至关重要。后续我们还会分享更多数据库操作的实战技巧,记得关注我们的公众号"服务端技术精选"!

觉得这篇文章对你有帮助吗?欢迎点赞、在看、转发三连,你的支持是我们持续创作的最大动力!


服务端技术精选 | 专注分享实用的后端技术干货

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-08 02:36:49 HTTP/2.0 GET : https://f.mffb.com.cn/a/473128.html
  2. 运行时间 : 0.148368s [ 吞吐率:6.74req/s ] 内存消耗:4,494.52kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=9578e0f8bd83a5a587173fc2247ff585
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000581s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000956s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000272s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000293s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000594s ]
  6. SELECT * FROM `set` [ RunTime:0.000228s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000719s ]
  8. SELECT * FROM `article` WHERE `id` = 473128 LIMIT 1 [ RunTime:0.006969s ]
  9. UPDATE `article` SET `lasttime` = 1770489409 WHERE `id` = 473128 [ RunTime:0.005659s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.003586s ]
  11. SELECT * FROM `article` WHERE `id` < 473128 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000828s ]
  12. SELECT * FROM `article` WHERE `id` > 473128 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001046s ]
  13. SELECT * FROM `article` WHERE `id` < 473128 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000845s ]
  14. SELECT * FROM `article` WHERE `id` < 473128 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.058351s ]
  15. SELECT * FROM `article` WHERE `id` < 473128 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001010s ]
0.149898s