Executes the inputted command into the current \
        connection cursor.
        
        :param      command    | <str>
                    data       | <dict> || None
                    autoCommit | <bool> | commit database changes immediately
                    autoClose  | <bool> | closes connections immediately
        
        :return     [{<str> key: <variant>, ..}, ..], <int> count

def _execute(self,
                 native,
                 command,
                 data=None,
                 returning=True,
                 mapper=dict):
        """
        Executes the inputted command into the current \
        connection cursor.
        
        :param      command    | <str>
                    data       | <dict> || None
                    autoCommit | <bool> | commit database changes immediately
                    autoClose  | <bool> | closes connections immediately
        
        :return     [{<str> key: <variant>, ..}, ..], <int> count
        """
        if data is None:
            data = {}

        # check to make sure the connection hasn't been reset or lost
        cursor = native.cursor()

        # determine if we're executing multiple statements at once
        commands = [cmd for cmd in command.split(';') if cmd]
        if len(commands) > 1:
            native.isolation_level = 'IMMEDIATE'
            commands.insert(0, 'BEGIN TRANSACTION')
        else:
            native.isolation_level = None

        def _gen_sub_value(val):
            output = []
            replace = []

            for sub_value in val:
                if isinstance(sub_value, (list, tuple, set)):
                    cmd, vals = _gen_sub_value(sub_value)
                    replace.append(cmd)
                    output += vals
                else:
                    replace.append('?')
                    output.append(sub_value)

                return '({0})'.format(','.join(replace)), output

        rowcount = 0
        for cmd in commands:
            if not cmd.endswith(';'):
                cmd += ';'

            # map the dictionary keywords to the param based for sqlite
            # (sqlite requires ordered options vs. keywords)
            args = []
            for grp, key in FORMAT_EXPR.findall(cmd):
                value = data[key]
                if isinstance(value, (list, tuple, set)):
                    replace, values = _gen_sub_value(value)
                    cmd = cmd.replace(grp, replace)
                    args += values
                else:
                    cmd = cmd.replace(grp, '?')
                    args.append(value)


            log.debug('***********************')
            log.debug(command)
            log.debug(args)
            log.debug('***********************')

            try:
                cursor.execute(cmd, tuple(args))

                if cursor.rowcount != -1:
                    rowcount += cursor.rowcount

            # look for a cancelled query
            except sqlite.OperationalError as err:
                if err == 'interrupted':
                    raise orb.errors.Interruption()
                else:
                    log.exception('Unkown query error.')
                    raise orb.errors.QueryFailed(cmd, args, nstr(err))

            # look for duplicate entries
            except sqlite.IntegrityError as err:
                duplicate_error = re.search('UNIQUE constraint failed: (.*)', nstr(err))
                if duplicate_error:
                    result = duplicate_error.group(1)
                    msg = '{value} is already being used.'.format(value=result)
                    raise orb.errors.DuplicateEntryFound(msg)
                else:
                    # unknown error
                    log.exception('Unknown query error.')
                    raise orb.errors.QueryFailed(command, data, nstr(err))

            # look for any error
            except Exception as err:
                log.exception('Unknown query error.')
                raise orb.errors.QueryFailed(cmd, args, nstr(err))

        if returning:
            results = [mapper(record) for record in cursor.fetchall()]
            rowcount = len(results)  # for some reason, rowcount in sqlite3 returns -1 for selects...
        else:
            results = []

        native.isolation_level = None
        native.commit()

        return results, rowcount