def execute(self, sql, dtype='tuple', limit=None, echo=True, query_name='Record', log=log):
    'Execute SQL, return last result'
    self.reconnect(min_tresh=10)
    data = None
    fields = None
    rows = []
    message_mapping = {'drop ': 'Dropping {}.', 'truncate ': 'Truncating {}.', 'select ': 'Selecting {}.', 'create ': 'Creating {}.', 'insert ': 'Inserting {}.', 'alter ': 'Altering {}.', 'update ': 'Updating {}.', 'delete ': 'Deleting {}.', 'exec ': 'Calling Procedure {}.', 'grant ': 'Granting {}.'}
    sql_ = sql.strip().lower()
    for (word, message) in message_mapping.items():
        if sql_.startswith(word):
            if echo:
                log(message.format(' '.join(sql_.splitlines()[0].split()[1:3]).upper()))
            break
    if sql_.startswith('exec '):
        procedure = sql_[5:].split('(')[0]
        args = sql_[5:].split('(')[1][:(- 1)].replace("'", '').split(',')
        args = [a.strip() for a in args]
        connection = self.engine.raw_connection()
        try:
            cursor = connection.cursor()
            cursor.callproc(procedure, args)
            self._fields = self._get_cursor_fields(cursor_desc=cursor.description)
            rows = list(cursor.fetchall())
            cursor.close()
            connection.commit()
            return (fields, rows)
        finally:
            connection.close()
    try:
        self._fields = []
        rows = self.query(sql, rec_name=query_name, dtype=dtype, limit=limit, echo=echo, log=log)
        fields = self._fields
        if (('-- pk_test:' in sql.lower()) and sql_.startswith('create')):
            sql_lines = sql_.splitlines()
            regexp = 'create\\s+table\\s+(\\S*)[\\sa-zA-Z\\d]+ as'
            table = re.findall(regexp, sql_lines[0])[0]
            line = [l for l in sql_lines if l.strip().lower().startswith('-- pk_test:')][0]
            fields = line.split(':')[(- 1)]
            self.check_pk(table, fields)
    except Exception as E:
        message = get_exception_message().lower()
        if (sql_.startswith('drop ') and (self.error_msg['table_not_exist'] in message)):
            log('WARNING: Table already dropped.')
        else:
            raise E
    if (not fields):
        fields = []
    return (fields, rows)
Execute SQL, return last result
def execute(self, sql, dtype='tuple', limit=None, echo=True, query_name='Record', log=log):
    
    self.reconnect(min_tresh=10)
    data = None
    fields = None
    rows = []
    message_mapping = {'drop ': 'Dropping {}.', 'truncate ': 'Truncating {}.', 'select ': 'Selecting {}.', 'create ': 'Creating {}.', 'insert ': 'Inserting {}.', 'alter ': 'Altering {}.', 'update ': 'Updating {}.', 'delete ': 'Deleting {}.', 'exec ': 'Calling Procedure {}.', 'grant ': 'Granting {}.'}
    sql_ = sql.strip().lower()
    for (word, message) in message_mapping.items():
        if sql_.startswith(word):
            if echo:
                log(message.format(' '.join(sql_.splitlines()[0].split()[1:3]).upper()))
            break
    if sql_.startswith('exec '):
        procedure = sql_[5:].split('(')[0]
        args = sql_[5:].split('(')[1][:(- 1)].replace("'", ).split(',')
        args = [a.strip() for a in args]
        connection = self.engine.raw_connection()
        try:
            cursor = connection.cursor()
            cursor.callproc(procedure, args)
            self._fields = self._get_cursor_fields(cursor_desc=cursor.description)
            rows = list(cursor.fetchall())
            cursor.close()
            connection.commit()
            return (fields, rows)
        finally:
            connection.close()
    try:
        self._fields = []
        rows = self.query(sql, rec_name=query_name, dtype=dtype, limit=limit, echo=echo, log=log)
        fields = self._fields
        if (('-- pk_test:' in sql.lower()) and sql_.startswith('create')):
            sql_lines = sql_.splitlines()
            regexp = 'create\\s+table\\s+(\\S*)[\\sa-zA-Z\\d]+ as'
            table = re.findall(regexp, sql_lines[0])[0]
            line = [l for l in sql_lines if l.strip().lower().startswith('-- pk_test:')][0]
            fields = line.split(':')[(- 1)]
            self.check_pk(table, fields)
    except Exception as E:
        message = get_exception_message().lower()
        if (sql_.startswith('drop ') and (self.error_msg['table_not_exist'] in message)):
            log('WARNING: Table already dropped.')
        else:
            raise E
    if (not fields):
        fields = []
    return (fields, rows)