Skip to the content
九天博客

下载综合症

  • 教程
  • 分享
  • 视频
  • 常用影视接口
  • 影视导航
  • 视频解析
  • Aria2下载
  • 在线M3U8播放器
  • 教程
  • 分享
  • 视频
  • 常用影视接口
  • 影视导航
  • 视频解析
  • Aria2下载
  • 在线M3U8播放器

Python Mysqlite类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import sqlite3
class EasySqlite:
    """
    sqlite数据库操作工具类
    database: 数据库文件地址,例如:db/mydb.db
    """
    _connection = None
    def __init__(self, database):
        # 连接数据库
        self._connection = sqlite3.connect(database)
    def _dict_factory(self, cursor, row):
        d = {}
        for idx, col in enumerate(cursor.description):
            d[col[0]] = row[idx]
        return d
    def execute(self, sql, args=[], result_dict=True, commit=True)->list:
        """
        执行数据库操作的通用方法
        Args:
        sql: sql语句
        args: sql参数
        result_dict: 操作结果是否用dict格式返回
        commit: 是否提交事务
        Returns:
        list 列表,例如:
        [{'id': 1, 'name': '张三'}, {'id': 2, 'name': '李四'}]
        """
        if result_dict:
            self._connection.row_factory = self._dict_factory
        else:
            self._connection.row_factory = None
        # 获取游标
        _cursor = self._connection.cursor()
        # 执行SQL获取结果
        _cursor.execute(sql, args)
        if commit:
            self._connection.commit()
        data = _cursor.fetchall()
        _cursor.close()
        return data

九天

下载综合征重度患者,已进入晚期。

Author archive Author website

2021年1月19日

教程

Previous post Next post

Comments are closed.

近期文章

  • OK影视apk
  • 密码保护:破解
  • Linux 网络流量监控利器 iftop 中文入门指南
  • 西瓜播放器
  • PHP简单的获取用户IP,系统,浏览器等信息

分类目录

  • 分享 (45)
  • 教程 (102)
  • 日常 (6)
  • 视频 (3)
  • 软件 (2)

标签

BT (1) C# (12) FFmpeg (3) GIF (1) JSON (2) linux (2) m3u8 (1) mysql (10) Nginx (1) PHP (10) PS (1) python (5) SRT (1) TS (1) VTT (1) 下载 (4) 九天 (1) 云监控 (1) 代码 (1) 免费 (1) 动图 (1) 合并 (2) 域名 (1) 字幕 (1) 字符串 (1) 录制 (1) 提取数字 (1) 搜索 (1) 教程 (2) 数字 (1) 数据库 (8) 时区 (1) 模糊查询 (1) 正则 (1) 番号 (1) 短信 (1) 磁力 (2) 种子 (2) 类 (2) 绿色 (1) 解密 (1) 迅雷 (1) 重复 (2) 随机 (1) 高速通道 (1)

近期评论

  • 九天发表在《网友留言》
  • 九天发表在《网友留言》
  • 九天发表在《网友留言》
  • 九天发表在《网友留言》
  • buy viagra发表在《这20张图能治愈最严重的强迫症患者》

九天系列

  • 1024超级搜索
  • 音乐解析

热门文章

  • EXCEL对身份证号进行信息提取
  • C#教程目录
  • 超级好用动图录制工具GIFCam2.0

联系我

留言板

© 2025 九天博客 — Powered by WordPress

Theme by Anders Noren — Up ↑