本文整理汇总了Python中_mysql_connector.MySQL.get_character_set_info方法的典型用法代码示例。如果您正苦于以下问题:Python MySQL.get_character_set_info方法的具体用法?Python MySQL.get_character_set_info怎么用?Python MySQL.get_character_set_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_mysql_connector.MySQL
的用法示例。
在下文中一共展示了MySQL.get_character_set_info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_character_set_info
# 需要导入模块: from _mysql_connector import MySQL [as 别名]
# 或者: from _mysql_connector.MySQL import get_character_set_info [as 别名]
def test_get_character_set_info(self):
cmy = MySQL()
self.assertRaises(MySQLInterfaceError, cmy.get_character_set_info)
cmy.connect(**self.connect_kwargs)
# We go by the default of MySQL, which is latin1/swedish_ci
exp = {'comment': '', 'name': 'latin1_swedish_ci',
'csname': 'latin1', 'mbmaxlen': 1, 'number': 8, 'mbminlen': 1}
result = cmy.get_character_set_info()
# make 'comment' deterministic
result['comment'] = ''
self.assertEqual(exp, result)
cmy.query("SET NAMES utf8")
cmy.set_character_set('utf8')
exp = {'comment': '', 'name': 'utf8_general_ci',
'csname': 'utf8', 'mbmaxlen': 3, 'number': 33, 'mbminlen': 1}
result = cmy.get_character_set_info()
# make 'comment' deterministic
result['comment'] = ''
self.assertEqual(exp, result)