mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-02 00:22:02 +00:00
[misc] correcting charset missing format identifier
This commit is contained in:
@ -271,7 +271,7 @@ MrdbConnection_Initialize(MrdbConnection *self,
|
||||
};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, dsnargs,
|
||||
"|sssssisiiipissssssssssipi:connect",
|
||||
"|sssssisiiipissssssssssipis:connect",
|
||||
dsn_keys,
|
||||
&dsn, &host, &user, &password, &schema, &port, &socket,
|
||||
&connect_timeout, &read_timeout, &write_timeout,
|
||||
|
@ -11,5 +11,6 @@ def create_connection(additional_conf=None):
|
||||
if additional_conf is None:
|
||||
c = {key: value for (key, value) in (default_conf.items())}
|
||||
else:
|
||||
c = {key: value for (key, value) in (default_conf.items() + additional_conf.items())}
|
||||
c = {key: value for (key, value) in (list(default_conf.items()) + list(
|
||||
additional_conf.items()))}
|
||||
return mariadb.connect(**c)
|
||||
|
@ -518,13 +518,40 @@ class TestCursor(unittest.TestCase):
|
||||
del cursor
|
||||
|
||||
def test_conpy21(self):
|
||||
conn = mariadb.connection(default_file='default.cnf')
|
||||
conn = self.connection
|
||||
cursor = conn.cursor()
|
||||
self.assertFalse(cursor.closed)
|
||||
conn.close()
|
||||
self.assertTrue(cursor.closed)
|
||||
del cursor, conn
|
||||
|
||||
def test_utf8(self):
|
||||
# F0 9F 98 8E 😎 unicode 6 smiling face with sunglasses
|
||||
# F0 9F 8C B6 🌶 unicode 7 hot pepper
|
||||
# F0 9F 8E A4 🎤 unicode 8 no microphones
|
||||
# F0 9F A5 82 🥂 unicode 9 champagne glass
|
||||
con = create_connection({"charset": "utf8mb4"})
|
||||
cursor = con.cursor()
|
||||
cursor.execute(
|
||||
"CREATE TEMPORARY TABLE `test_utf8` (`test` blob)")
|
||||
cursor.execute("INSERT INTO test_utf8 VALUES (?)", ("😎🌶🎤🥂",))
|
||||
cursor.execute("SELECT * FROM test_utf8")
|
||||
row = cursor.fetchone()
|
||||
self.assertEqual(row[0], b"\xf0\x9f\x98\x8e\xf0\x9f\x8c\xb6\xf0\x9f\x8e\xa4\xf0\x9f\xa5\x82")
|
||||
del cursor, con
|
||||
|
||||
def test_latin2(self):
|
||||
con = create_connection({"charset": "cp1251"})
|
||||
cursor = con.cursor()
|
||||
cursor.execute(
|
||||
"CREATE TEMPORARY TABLE `test_latin2` (`test` blob)")
|
||||
cursor.execute("INSERT INTO test_latin2 VALUES (?)", ("©°",))
|
||||
cursor.execute("SELECT * FROM test_latin2")
|
||||
row = cursor.fetchone()
|
||||
self.assertEqual(row[0], b"\xA9\xB0")
|
||||
del cursor, con
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user