def execute_query(self, query, caller=None):
        """
        Send arbitrary SQLite query to the database.

        :param str query: Query to executed.
        :param tuple caller:
            Caller information.
            Expects the return value of :py:meth:`logging.Logger.findCaller`.
        :return: The result of the query execution.
        :rtype: sqlite3.Cursor
        :raises simplesqlite.NullDatabaseConnectionError:
            |raises_check_connection|
        :raises simplesqlite.OperationalError: |raises_operational_error|

        .. warning::
            This method can execute an arbitrary query.
            i.e. No access permissions check by |attr_mode|.
        """

        import time

        self.check_connection()
        if typepy.is_null_string(query):
            return None

        if self.debug_query or self.global_debug_query:
            logger.debug(query)

        if self.__is_profile:
            exec_start_time = time.time()

        try:
            result = self.connection.execute(six.text_type(query))
        except (sqlite3.OperationalError, sqlite3.IntegrityError) as e:
            if caller is None:
                caller = logging.getLogger().findCaller()
            file_path, line_no, func_name = caller[:3]

            raise OperationalError(
                message="\n".join(
                    [
                        "failed to execute query at {:s}({:d}) {:s}".format(
                            file_path, line_no, func_name
                        ),
                        "  - query: {}".format(MultiByteStrDecoder(query).unicode_str),
                        "  - msg:   {}".format(e),
                        "  - db:    {}".format(self.database_path),
                    ]
                )
            )

        if self.__is_profile:
            self.__dict_query_count[query] = self.__dict_query_count.get(query, 0) + 1

            elapse_time = time.time() - exec_start_time
            self.__dict_query_totalexectime[query] = (
                self.__dict_query_totalexectime.get(query, 0) + elapse_time
            )

        return result
def execute_query ( self , query , caller = None ) : import time self . check_connection ( ) if typepy . is_null_string ( query ) : return None if self . debug_query or self . global_debug_query : logger . debug ( query ) if self . __is_profile : exec_start_time = time . time ( ) try : result = self . connection . execute ( six . text_type ( query ) ) except ( sqlite3 . OperationalError , sqlite3 . IntegrityError ) as e : if caller is None : caller = logging . getLogger ( ) . findCaller ( ) file_path , line_no , func_name = caller [ : 3 ] raise OperationalError ( message = "\n" . join ( [ "failed to execute query at {:s}({:d}) {:s}" . format ( file_path , line_no , func_name ) , "  - query: {}" . format ( MultiByteStrDecoder ( query ) . unicode_str ) , "  - msg:   {}" . format ( e ) , "  - db:    {}" . format ( self . database_path ) , ] ) ) if self . __is_profile : self . __dict_query_count [ query ] = self . __dict_query_count . get ( query , 0 ) + 1 elapse_time = time . time ( ) - exec_start_time self . __dict_query_totalexectime [ query ] = ( self . __dict_query_totalexectime . get ( query , 0 ) + elapse_time ) return result
Send arbitrary SQLite query to the database.

        :param str query: Query to executed.
        :param tuple caller:
            Caller information.
            Expects the return value of :py:meth:`logging.Logger.findCaller`.
        :return: The result of the query execution.
        :rtype: sqlite3.Cursor
        :raises simplesqlite.NullDatabaseConnectionError:
            |raises_check_connection|
        :raises simplesqlite.OperationalError: |raises_operational_error|

        .. warning::
            This method can execute an arbitrary query.
            i.e. No access permissions check by |attr_mode|.