Modelのverbose_name(その4)

set namesを実行してもcharacter_set_name()の値に変わりはない。MySQL APIのバグなのだろうか?それともMySQLdb1.2.0のバグ?

>>> import MySQLdb
>>> c = MySQLdb.connect(db='hoge', user='foo', passwd='bar', use_unicode=True)
>>> c.character_set_name()
'latin1_swedish_ci'
>>> cur = c.cursor()
>>> cur.execute("show variables like '%char%'")
8L
>>> r = cur.fetchone()
>>> while r != None:
... print r
... r = cur.fetchone()
...
(u'character_set_client', u'latin1')
(u'character_set_connection', u'latin1')
(u'character_set_database', u'utf8')
(u'character_set_filesystem', u'binary')
(u'character_set_results', u'latin1')
(u'character_set_server', u'utf8')
(u'character_set_system', u'utf8')
(u'character_sets_dir', u'C:\\Program Files\\MySQL\\MySQL Server 5.0\\share\\cha
rsets\\')
>>> cur.execute("set names utf8")
0L
>>> cur.execute("show variables like '%char%'")
8L
>>> r = cur.fetchone()
>>> while r != None:
... print r
... r = cur.fetchone()
...
(u'character_set_client', u'utf8')
(u'character_set_connection', u'utf8')
(u'character_set_database', u'utf8')
(u'character_set_filesystem', u'binary')
(u'character_set_results', u'utf8')
(u'character_set_server', u'utf8')
(u'character_set_system', u'utf8')
(u'character_sets_dir', u'C:\\Program Files\\MySQL\\MySQL Server 5.0\\share\\cha
rsets\\')
>>> c.character_set_name()
'latin1_swedish_ci'

MySQLdb1.2.1にはset_character_set_name()が追加されているらしいと言うので、1.2.1_p2をインストールして見たら、こんなエラーが出て動かない。どうやらバグらしい。

>>> import MySQLdb
Traceback (most recent call last):
File "", line 1, in ?
File "C:\Python24\lib\site-packages\MySQLdb\__init__.py", line 34, in ?
from sets import ImmutableSet
ImportError: cannot import name ImmutableSet