当前位置:首页>python>Python 零基础100天—Day46 Python 操作 SQLite

Python 零基础100天—Day46 Python 操作 SQLite

  • 2026-06-30 06:19:40
Python 零基础100天—Day46 Python 操作 SQLite

🐍 Python Day46:Python 操作 SQLite — 用代码管理数据库

🕐 预计用时:2-3 小时 | 🎯 目标:掌握 sqlite3 模块、连接/游标、参数化查询、事务


📖 今日目录

  1. SQLite 简介
  2. 连接数据库与游标
  3. 创建表
  4. 插入数据 (INSERT)
  5. 查询数据 (SELECT)
  6. 参数化查询 — 防 SQL 注入
  7. 更新与删除
  8. 事务 (Transaction)
  9. 上下文管理器
  10. 实战:通讯录管理
  11. 今日小结

1. SQLite 简介

SQLite 是 Python 内置的轻量级数据库——整个数据库就是一个文件,无需安装服务器。

# SQLite 的优势
# 1. Python 内置,不需要额外安装
# 2. 整个数据库就是一个 .db 文件
# 3. 适合小型应用、本地存储、原型开发
# 4. 支持标准 SQL 语法

# 适用场景
# ✅ 本地数据存储(配置、缓存、日志)
# ✅ 小型应用(<10万条数据)
# ✅ 原型开发和测试
# ❌ 高并发写入(只支持一个写入者)
# ❌ 大规模数据(>1GB 建议用 MySQL/PostgreSQL)

2. 连接数据库与游标

import sqlite3

# 连接数据库(文件不存在会自动创建)
conn = sqlite3.connect("mydata.db")

# 创建游标(执行 SQL 的工具)
cursor = conn.cursor()

# 执行 SQL
cursor.execute("SELECT sqlite_version()")
version = cursor.fetchone()
print(f"SQLite 版本: {version[0]}")

# 关闭连接
cursor.close()
conn.close()
# 获取查询结果的三种方式
import sqlite3

conn = sqlite3.connect("mydata.db")
cursor = conn.cursor()

cursor.execute("SELECT name, age FROM students")

# 方式1: fetchone() — 取一行
row = cursor.fetchone()
print(row)  # ('张三', 20)

# 方式2: fetchall() — 取所有行
rows = cursor.fetchall()
print(rows)  # [('张三', 20), ('李四', 22), ...]

# 方式3: 直接迭代游标
for row in cursor.execute("SELECT name, age FROM students"):
    print(f"{row[0]}: {row[1]}岁")

conn.close()

⚠️ 记住关闭连接!不关闭会导致数据库文件锁定,其他程序无法访问。推荐用 with 语句(后面会讲)。


3. 创建表

import sqlite3

conn = sqlite3.connect("school.db")
cursor = conn.cursor()

# 创建学生表
cursor.execute("""
CREATE TABLE IF NOT EXISTS students (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    age INTEGER CHECK(age > 0 AND age < 150),
    gender TEXT DEFAULT '未知',
    class TEXT NOT NULL,
    email TEXT UNIQUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
""")

# 创建成绩表
cursor.execute("""
CREATE TABLE IF NOT EXISTS scores (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    student_id INTEGER NOT NULL,
    subject TEXT NOT NULL,
    score REAL CHECK(score >= 0 AND score <= 100),
    FOREIGN KEY (student_id) REFERENCES students(id)
)
""")

conn.commit()  # 提交更改
conn.close()

print("✅ 表创建成功")

4. 插入数据 (INSERT)

import sqlite3

conn = sqlite3.connect("school.db")
cursor = conn.cursor()

# 插入单条数据
cursor.execute(
    "INSERT INTO students (name, age, gender, class) VALUES (?, ?, ?, ?)",
    ("张三", 20, "男", "一班")
)

# 插入多条数据
students = [
    ("李四", 22, "女", "二班"),
    ("王五", 21, "男", "一班"),
    ("赵六", 23, "男", "二班"),
    ("钱七", 20, "女", "一班"),
]
cursor.executemany(
    "INSERT INTO students (name, age, gender, class) VALUES (?, ?, ?, ?)",
    students
)

# 获取最后插入的 ID
print(f"最后插入的 ID: {cursor.lastrowid}")

conn.commit()
conn.close()
print(f"✅ 插入 {len(students) + 1} 条数据")

5. 查询数据 (SELECT)

import sqlite3

conn = sqlite3.connect("school.db")
cursor = conn.cursor()

# 查询所有
cursor.execute("SELECT * FROM students")
all_students = cursor.fetchall()
for s in all_students:
    print(f"  ID={s[0]} | {s[1]} | {s[2]}岁 | {s[3]} | {s[4]}班")

# 查询单条
cursor.execute("SELECT name, age FROM students WHERE id = ?", (1,))
student = cursor.fetchone()
print(f"\n查询 ID=1: {student}")

# 查询并排序
cursor.execute("SELECT name, age FROM students ORDER BY age DESC")
for row in cursor.fetchall():
    print(f"  {row[0]}: {row[1]}岁")

# 查询并统计
cursor.execute("SELECT COUNT(*) FROM students")
count = cursor.fetchone()[0]
print(f"\n总人数: {count}")

# 分页查询
page = 1
page_size = 2
offset = (page - 1) * page_size
cursor.execute("SELECT name FROM students LIMIT ? OFFSET ?", (page_size, offset))
print(f"\n第{page}页: {cursor.fetchall()}")

conn.close()

6. 参数化查询 — 防 SQL 注入

import sqlite3

conn = sqlite3.connect("school.db")
cursor = conn.cursor()

# ❌ 危险!字符串拼接(SQL 注入风险)
user_input = "张三' OR '1'='1"
query = f"SELECT * FROM students WHERE name = '{user_input}'"
print(f"恶意查询: {query}")
# SELECT * FROM students WHERE name = '张三' OR '1'='1'
# 这会返回所有数据!
cursor.execute(query)  # 千万不要这样做!

# ✅ 安全!参数化查询
cursor.execute("SELECT * FROM students WHERE name = ?", (user_input,))
result = cursor.fetchall()
print(f"安全查询结果: {result}")  # [](没有匹配,因为没有叫那个名字的人)

# 参数化查询用 ? 占位符,数据库会自动转义参数
# 绝对安全,不会被 SQL 注入

conn.close()

⚠️ 永远不要用字符串拼接构造 SQL!
❌ f"SELECT * FROM users WHERE name = '{name}'"
✅ cursor.execute("SELECT * FROM users WHERE name = ?", (name,))


7. 更新与删除

import sqlite3

conn = sqlite3.connect("school.db")
cursor = conn.cursor()

# 更新数据
cursor.execute(
    "UPDATE students SET age = ? WHERE name = ?",
    (21, "张三")
)
print(f"更新了 {cursor.rowcount} 行")  # rowcount = 受影响的行数

# 删除数据
cursor.execute("DELETE FROM students WHERE name = ?", ("赵六",))
print(f"删除了 {cursor.rowcount} 行")

conn.commit()

# 验证
cursor.execute("SELECT name, age FROM students")
for row in cursor.fetchall():
    print(f"  {row[0]}: {row[1]}岁")

conn.close()

8. 事务 (Transaction)

import sqlite3

conn = sqlite3.connect("school.db")
cursor = conn.cursor()

# 事务:要么全部成功,要么全部回滚
try:
    # 转账:张三 -100,李四 +100
    cursor.execute("UPDATE accounts SET balance = balance - 100 WHERE name = '张三'")
    cursor.execute("UPDATE accounts SET balance = balance + 100 WHERE name = '李四'")

    # 两条都成功才提交
    conn.commit()
    print("✅ 转账成功")
except Exception as e:
    # 任何一条失败就回滚
    conn.rollback()
    print(f"❌ 转账失败,已回滚: {e}")

# SQLite 默认自动提交(autocommit)
# 用 conn.commit() 手动提交事务
# 用 conn.rollback() 回滚事务

💡 事务的 ACID 特性:
• Atomicity(原子性):要么全部成功,要么全部失败
• Consistency(一致性):数据始终保持合法状态
• Isolation(隔离性):并发事务互不干扰
• Durability(持久性):提交后数据永久保存


9. 上下文管理器

import sqlite3

# ✅ 推荐:用 with 语句自动管理连接
with sqlite3.connect("school.db") as conn:
    cursor = conn.cursor()
    cursor.execute("SELECT name FROM students")
    print(cursor.fetchall())
# with 块结束时自动 commit,出错时自动 rollback

# 封装一个数据库操作类
class Database:
    def __init__(self, db_path):
        self.db_path = db_path

    def __enter__(self):
        self.conn = sqlite3.connect(self.db_path)
        self.conn.row_factory = sqlite3.Row  # 让查询结果像字典一样访问
        return self.conn.cursor()

    def __exit__(self, exc_type, exc_val, exc_tb):
        if exc_type:
            self.conn.rollback()
        else:
            self.conn.commit()
        self.conn.close()

# 使用
with Database("school.db") as db:
    db.execute("SELECT name, age FROM students")
    for row in db.fetchall():
        print(f"  {row['name']}: {row['age']}岁")  # 可以用列名访问

10. 实战:通讯录管理

import sqlite3

class ContactDB:
    """通讯录数据库管理"""

    def __init__(self, db_path="contacts.db"):
        self.conn = sqlite3.connect(db_path)
        self.conn.row_factory = sqlite3.Row
        self.cursor = self.conn.cursor()
        self._create_table()

    def _create_table(self):
        self.cursor.execute("""
        CREATE TABLE IF NOT EXISTS contacts (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            name TEXT NOT NULL,
            phone TEXT,
            email TEXT,
            group_name TEXT DEFAULT '默认',
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        )
        """)
        self.conn.commit()

    def add(self, name, phone="", email="", group="默认"):
        """添加联系人"""
        self.cursor.execute(
            "INSERT INTO contacts (name, phone, email, group_name) VALUES (?, ?, ?, ?)",
            (name, phone, email, group)
        )
        self.conn.commit()
        return self.cursor.lastrowid

    def search(self, keyword):
        """搜索联系人"""
        self.cursor.execute(
            "SELECT * FROM contacts WHERE name LIKE ? OR phone LIKE ?",
            (f"%{keyword}%", f"%{keyword}%")
        )
        return self.cursor.fetchall()

    def get_all(self, group=None):
        """获取所有联系人"""
        if group:
            self.cursor.execute("SELECT * FROM contacts WHERE group_name = ?", (group,))
        else:
            self.cursor.execute("SELECT * FROM contacts ORDER BY name")
        return self.cursor.fetchall()

    def update(self, contact_id, **kwargs):
        """更新联系人"""
        allowed = {"name", "phone", "email", "group_name"}
        updates = {k: v for k, v in kwargs.items() if k in allowed and v is not None}
        if not updates:
            return

        set_clause = ", ".join(f"{k} = ?" for k in updates)
        values = list(updates.values()) + [contact_id]
        self.cursor.execute(f"UPDATE contacts SET {set_clause} WHERE id = ?", values)
        self.conn.commit()
        return self.cursor.rowcount

    def delete(self, contact_id):
        """删除联系人"""
        self.cursor.execute("DELETE FROM contacts WHERE id = ?", (contact_id,))
        self.conn.commit()
        return self.cursor.rowcount

    def close(self):
        self.conn.close()

# 使用
db = ContactDB()

# 添加联系人
db.add("张三", "13800138001", "zhangsan@example.com", "朋友")
db.add("李四", "13800138002", "lisi@example.com", "同事")
db.add("王五", "13800138003", group="朋友")
db.add("赵六", "13800138004", "zhaoliu@example.com")

# 搜索
print("🔍 搜索 '张三':")
for c in db.search("张三"):
    print(f"  {c['name']} | {c['phone']} | {c['email']}")

# 按组查看
print("\n👥 '朋友' 组:")
for c in db.get_all("朋友"):
    print(f"  {c['name']} | {c['phone']}")

# 更新
db.update(1, phone="13900139000")
print(f"\n✏️ 更新张三电话: 修改了 {db.update(1, phone='13900139000')} 行")

# 删除
db.delete(3)
print(f"\n🗑️ 删除王五: 修改了 {db.delete(3)} 行")

# 查看所有
print("\n📋 所有联系人:")
for c in db.get_all():
    print(f"  [{c['group_name']}] {c['name']} | {c['phone']} | {c['email']}")

db.close()

11. 今日小结

操作
代码
连接数据库
sqlite3.connect("file.db")
创建游标
conn.cursor()
执行 SQL
cursor.execute(sql, params)
查询一条
cursor.fetchone()
查询所有
cursor.fetchall()
提交事务
conn.commit()
回滚事务
conn.rollback()
参数化查询
WHERE name = ?

🎯 练习建议:
1. 给通讯录添加"分页查询"和"按组统计"功能
2. 用 SQLite 实现一个"每日记事本"(按日期存储和查询)
3. 把之前爬取的豆瓣 Top250 CSV 导入 SQLite 数据库


📚 Day46 完成!明天学习 Python 操作 MySQL

轻松时刻:

请在微信客户端打开

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 08:09:45 HTTP/2.0 GET : https://f.mffb.com.cn/a/502113.html
  2. 运行时间 : 0.122809s [ 吞吐率:8.14req/s ] 内存消耗:4,670.21kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=f128a4a7d0ea142e5bf1a92961359c07
  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.000931s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000853s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000343s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000292s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000512s ]
  6. SELECT * FROM `set` [ RunTime:0.000219s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000601s ]
  8. SELECT * FROM `article` WHERE `id` = 502113 LIMIT 1 [ RunTime:0.000485s ]
  9. UPDATE `article` SET `lasttime` = 1783037385 WHERE `id` = 502113 [ RunTime:0.018744s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000445s ]
  11. SELECT * FROM `article` WHERE `id` < 502113 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000631s ]
  12. SELECT * FROM `article` WHERE `id` > 502113 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000563s ]
  13. SELECT * FROM `article` WHERE `id` < 502113 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.014819s ]
  14. SELECT * FROM `article` WHERE `id` < 502113 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002085s ]
  15. SELECT * FROM `article` WHERE `id` < 502113 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001499s ]
0.124777s