sqlite3.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:asyncqlio 作者: SunDwarf 项目源码 文件源码
def execute(self, sql: str, params: typing.Union[typing.Mapping, typing.Iterable] = None):
        """
        Executes SQL in the current transaction.
        """
        # lock to ensure nothing else is using the connection at once

        logger.debug("Running SQL {} with params {}".format(sql, params))
        async with self._lock:
            async with threadpool():
                for stmt in separate_statements(sql):
                    try:
                        if params is None:
                            res = self.connection.execute(stmt)
                        else:
                            res = self.connection.execute(stmt, params)
                    except sqlite3.IntegrityError as e:
                        raise IntegrityError(*e.args)
                    except sqlite3.OperationalError as e:
                        raise DatabaseException(*e.args)

            return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号