本文整理汇总了Python中_mysql_connector.MySQL.character_set_name方法的典型用法代码示例。如果您正苦于以下问题:Python MySQL.character_set_name方法的具体用法?Python MySQL.character_set_name怎么用?Python MySQL.character_set_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_mysql_connector.MySQL
的用法示例。
在下文中一共展示了MySQL.character_set_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_character_set_name
# 需要导入模块: from _mysql_connector import MySQL [as 别名]
# 或者: from _mysql_connector.MySQL import character_set_name [as 别名]
def test_character_set_name(self):
cmy1 = MySQL(buffered=True)
self.assertRaises(MySQLInterfaceError, cmy1.character_set_name)
cmy1.connect(**self.connect_kwargs)
self.assertEqual('latin1', cmy1.character_set_name())
示例2: test_set_character_set
# 需要导入模块: from _mysql_connector import MySQL [as 别名]
# 或者: from _mysql_connector.MySQL import character_set_name [as 别名]
def test_set_character_set(self):
cmy1 = MySQL(buffered=True)
self.assertRaises(MySQLInterfaceError, cmy1.set_character_set, 'latin2')
cmy1.connect(**self.connect_kwargs)
orig = cmy1.character_set_name()
cmy1.set_character_set('utf8')
charset = cmy1.character_set_name()
self.assertNotEqual(orig, charset)
self.assertEqual('utf8', charset)
self.assertRaises(MySQLInterfaceError,
cmy1.set_character_set, 'ham_spam')
variables = ('character_set_connection',)
exp = {b'character_set_connection': b'utf8',}
self.assertEqual(exp, get_variables(cmy1, variables=variables))
exp = {b'character_set_connection': b'big5',}
cmy1.set_character_set('big5')
self.assertEqual(exp, get_variables(cmy1, variables=variables))
示例3: test___init__
# 需要导入模块: from _mysql_connector import MySQL [as 别名]
# 或者: from _mysql_connector.MySQL import character_set_name [as 别名]
def test___init__(self):
cmy = MySQL()
self.assertEqual(False, cmy.buffered())
self.assertEqual(False, cmy.raw())
cmy = MySQL(buffered=True, raw=True)
self.assertEqual(True, cmy.buffered())
self.assertEqual(True, cmy.raw())
exp = 'gbk'
cmy = MySQL(charset_name=exp)
cmy.connect(**self.connect_kwargs)
self.assertEqual(exp, cmy.character_set_name())