'Sniff out the character set in use for connection results.'

def _detect_charset(self, connection):

    rs = connection.execute("SHOW    VARIABLES    LIKE    'character_set%%'")
    opts = dict(((row[0], row[1]) for row in self._compat_fetchall(rs)))
    for key in ('character_set_connection', 'character_set'):
        if opts.get(key, None):
            return opts[key]
    util.warn('Could    not    detect    the    connection    character    set.        Assuming    latin1.')
    return 'latin1'
