예제 #1
0
    def parse_string(self,
                     sql,
                     method_name,
                     include_path='sql',
                     bypass_types=False,
                     lazy=False):
        """
        Build a function from a string containing a SQL query

        If the number of parsed methods is bigger of the APSW SQLite bytecode
        cache it shows an alert because performance will decrease.

        :param sql: the SQL code of the method to be parsed
        :type sql: string
        :param method_name: the name of the method
        :type method_name: string
        :param dir_path: path to the dir with the SQL files (for INCLUDE)
        :type dir_path: string
        :param bypass_types: set if parsing should bypass types
        :type bypass_types: boolean
        :param lazy: set if parsing should be postpone until required
        :type lazy: boolean

        :return: the parsed function or None if `lazy` is True
        :rtype: function or None
        """
        result = Base.parse_string(self, sql, method_name, include_path,
                                   bypass_types, lazy)

        self._cachedmethods += 1
        if self._cachedmethods > self._max_cachedmethods:
            warning("Surpased APSW cache size (methods: %s; limit: %s)",
                    (self._cachedmethods, self._max_cachedmethods))

        return result
예제 #2
0
파일: sqlite.py 프로젝트: piranna/AntiORM
    def __init__(self, db_conn, dir_path=None, bypass_types=False, lazy=False):
        """
        Constructor

        @param db_conn: connection of the database
        @type db_conn: DB-API 2.0 database connection
        @param dir_path: path of the dir with files from where to load SQL code
        @type dir_path: string
        @param bypass_types: set if types should be bypassed on calling
        @type bypass_types: boolean
        @param lazy: set if SQL code at dir_path should be lazy loaded
        @type lazy: boolean
        """
        Base.__init__(self, db_conn, dir_path, bypass_types, lazy)

        self.tx_manager = db_conn
예제 #3
0
파일: apsw.py 프로젝트: piranna/AntiORM
    def parse_string(self, sql, method_name, include_path='sql',
                     bypass_types=False, lazy=False):
        """
        Build a function from a string containing a SQL query

        If the number of parsed methods is bigger of the APSW SQLite bytecode
        cache it shows an alert because performance will decrease.

        :param sql: the SQL code of the method to be parsed
        :type sql: string
        :param method_name: the name of the method
        :type method_name: string
        :param dir_path: path to the dir with the SQL files (for INCLUDE)
        :type dir_path: string
        :param bypass_types: set if parsing should bypass types
        :type bypass_types: boolean
        :param lazy: set if parsing should be postpone until required
        :type lazy: boolean

        :return: the parsed function or None if `lazy` is True
        :rtype: function or None
        """
        result = Base.parse_string(self, sql, method_name, include_path,
                                   bypass_types, lazy)

        self._cachedmethods += 1
        if self._cachedmethods > self._max_cachedmethods:
            warning("Surpased APSW cache size (methods: %s; limit: %s)",
                    (self._cachedmethods, self._max_cachedmethods))

        return result
예제 #4
0
파일: generic.py 프로젝트: piranna/AntiORM
    def __init__(self, db_conn, dir_path=None, bypass_types=False, lazy=False):
        """
        Constructor

        @param db_conn: connection of the database
        @type db_conn: DB-API 2.0 database connection
        @param dir_path: path of the dir with files from where to load SQL code
        @type dir_path: string
        @param bypass_types: set if types should be bypassed on calling
        @type bypass_types: boolean
        @param lazy: set if SQL code at dir_path should be lazy loaded
        @type lazy: boolean
        """
        # Check if database connection is from APSW so we force the wrapper
        if db_conn.__class__.__module__ == 'apsw':
            db_conn = APSWConnection(db_conn)
        else:
            db_conn = GenericConnection(db_conn)
        Base.__init__(self, db_conn, dir_path, bypass_types, lazy)

        self.tx_manager = TransactionManager(db_conn)
예제 #5
0
파일: generic.py 프로젝트: piranna/AntiORM
    def __init__(self, db_conn, dir_path=None, bypass_types=False, lazy=False):
        """
        Constructor

        @param db_conn: connection of the database
        @type db_conn: DB-API 2.0 database connection
        @param dir_path: path of the dir with files from where to load SQL code
        @type dir_path: string
        @param bypass_types: set if types should be bypassed on calling
        @type bypass_types: boolean
        @param lazy: set if SQL code at dir_path should be lazy loaded
        @type lazy: boolean
        """
        # Check if database connection is from APSW so we force the wrapper
        if db_conn.__class__.__module__ == 'apsw':
            db_conn = APSWConnection(db_conn)
        else:
            db_conn = GenericConnection(db_conn)
        Base.__init__(self, db_conn, dir_path, bypass_types, lazy)

        self.tx_manager = TransactionManager(db_conn)