runner.py 文件源码

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

项目:django-north 作者: peopledoc 项目源码 文件源码
def run(self, connection):
        statements = sqlparse.parse(self.content)

        content = "".join((six.text_type(stmt) for stmt in statements))
        if content != self.content:
            raise SQLRunnerException("sqlparse failed to properly split input")

        rows = 0
        with connection.cursor() as cursor:
            for statement in statements:
                if clean_sql_code(str(statement)).strip() in ("", ";"):
                    # Sometimes sqlparse keeps the empty lines here,
                    # this could negatively affect libpq
                    continue
                logger.debug("Running one statement... <<%s>>", str(statement))
                cursor.execute(str(statement).replace("\\timing\n", ""))
                logger.debug("Affected %s rows", cursor.rowcount)
                rows += cursor.rowcount
        return rows
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号