SQLObjectStore.py 文件源码

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

项目:w4py 作者: Cito 项目源码 文件源码
def executeSQL(self, sql, connection=None, commit=False):
        """Execute the given SQL.

        This will connect to the database for the first time if necessary.
        This method will also log the SQL to self._sqlEcho, if it is not None.
        Returns the connection and cursor used and relies on connectionAndCursor()
        to obtain these. Note that you can pass in a connection to force a
        particular one to be used and a flag to commit immediately.
        """
        sql = str(sql)  # Excel-based models yield Unicode strings which some db modules don't like
        sql = sql.strip()
        if aggressiveGC:
            import gc
            assert gc.isenabled()
            gc.collect()
        self._sqlCount += 1
        if self._sqlEcho:
            timestamp = funcs.timestamp()['pretty']
            self._sqlEcho.write('SQL %04i. %s %s\n' % (self._sqlCount, timestamp, sql))
            self._sqlEcho.flush()
        conn, cur = self.connectionAndCursor(connection)
        self._executeSQL(cur, sql)
        if commit:
            conn.commit()
        return conn, cur
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号