summaryrefslogtreecommitdiff
path: root/MySQLdb
diff options
context:
space:
mode:
authorEvax Software <contact@evax.fr>2012-10-08 19:15:52 +0200
committerEvax Software <contact@evax.fr>2012-10-08 19:16:01 +0200
commit030d175754fb6b296786449e124dfc86a79e79b2 (patch)
treedf179b43355b713e6e9b8dc4b92682c466f9bfd0 /MySQLdb
parent9eb906e8a7ef92e1523dc65a85978130cced7e20 (diff)
downloadmysqldb1-030d175754fb6b296786449e124dfc86a79e79b2.tar.gz
Use db.unicode_literal.charset in cursors.py
Diffstat (limited to 'MySQLdb')
-rw-r--r--MySQLdb/cursors.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py
index 3023fa3..7e5a887 100644
--- a/MySQLdb/cursors.py
+++ b/MySQLdb/cursors.py
@@ -47,9 +47,6 @@ from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \
NotSupportedError, ProgrammingError
-def normalize_utf8mb4(charset):
- return 'utf8' if charset == 'utf8mb4' else charset
-
class BaseCursor(object):
"""A base for Cursor classes. Useful attributes:
@@ -180,9 +177,8 @@ class BaseCursor(object):
"""
del self.messages[:]
db = self._get_db()
- charset = normalize_utf8mb4(db.character_set_name())
if isinstance(query, unicode):
- query = query.encode(charset)
+ query = query.encode(db.unicode_literal.charset)
if args is not None:
query = query % db.literal(args)
try:
@@ -228,8 +224,8 @@ class BaseCursor(object):
del self.messages[:]
db = self._get_db()
if not args: return
- charset = normalize_utf8mb4(db.character_set_name())
- if isinstance(query, unicode): query = query.encode(charset)
+ if isinstance(query, unicode):
+ query = query.encode(db.unicode_literal.charset)
m = insert_values.search(query)
if not m:
r = 0
@@ -288,12 +284,11 @@ class BaseCursor(object):
"""
db = self._get_db()
- charset = db.character_set_name()
for index, arg in enumerate(args):
q = "SET @_%s_%d=%s" % (procname, index,
db.literal(arg))
if isinstance(q, unicode):
- q = q.encode(charset)
+ q = q.encode(db.unicode_literal.charset)
self._query(q)
self.nextset()
@@ -301,7 +296,7 @@ class BaseCursor(object):
','.join(['@_%s_%d' % (procname, i)
for i in range(len(args))]))
if type(q) is UnicodeType:
- q = q.encode(charset)
+ q = q.encode(db.unicode_literal.charset)
self._query(q)
self._executed = q
if not self._defer_warnings: self._warning_check()