[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8242 - trunk/gnue-common/src/datasources/drivers/sql/mysql
From: |
jan |
Subject: |
[gnue] r8242 - trunk/gnue-common/src/datasources/drivers/sql/mysql |
Date: |
Mon, 20 Mar 2006 07:12:04 -0600 (CST) |
Author: jan
Date: 2006-03-20 07:12:04 -0600 (Mon, 20 Mar 2006)
New Revision: 8242
Modified:
trunk/gnue-common/src/datasources/drivers/sql/mysql/mysqldbdrv.py
Log:
set mysqldb drv connection encoding correctly
Modified: trunk/gnue-common/src/datasources/drivers/sql/mysql/mysqldbdrv.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/mysql/mysqldbdrv.py
2006-03-20 12:21:38 UTC (rev 8241)
+++ trunk/gnue-common/src/datasources/drivers/sql/mysql/mysqldbdrv.py
2006-03-20 13:12:04 UTC (rev 8242)
@@ -74,7 +74,7 @@
* dbname -- This is the name of the database to use (required)
* port -- This is the port where the server is running (optional)
* unicode -- Enables/disable unicode connection mode (optional,
default=true)
-* encoding -- This is the GNUe encoding for the database, if unicode mode is
disabled (optional, default="utf-8")
+* encoding -- Charset used for the database connection (default="utf-8")
Examples
--------
@@ -136,6 +136,12 @@
else:
kwargs [dbName] = connectData [gnueName]
+ if mySQL_encTable.has_key (self._encoding):
+ kwargs ['init_command'] = ('SET NAMES %s' %
mySQL_encTable[self._encoding])
+ else:
+ assert gDebug (1, "Encoding '%s' is not supported by mysql dbdriver. "
+ "Using default encoding." % self._encoding)
+
return ([], kwargs)
@@ -144,9 +150,14 @@
# ---------------------------------------------------------------------------
def _beginTransaction_ (self):
+
+ # fix encoding setting of driver
+ if mySQL_encTable.has_key (self._encoding):
+ self._native.charset = self._encoding
+
# only available if MySQL is compiled with transaction support
try:
- self.sql1("BEGIN")
+ self.sql0("BEGIN")
# self._native.begin ()
except:
pass
@@ -166,3 +177,46 @@
# def getSequence (self, name):
# (not available in MySQL)
+
+
+
+# =============================================================================
+# Encoding-Table
+# =============================================================================
+
+mySQL_encTable = {
+ 'ascii' : 'ascii', # ASCII
+ 'big5' : 'big5', # Big5 Traditional Chinese
+ 'gb2312' : 'gb2312', # GB2312 Simplified Chinese
+ 'gbk' : 'gbk', # GBK Simplified Chinese
+ '' : 'dec8', # DEC West European
+ '' : 'ujis', # Japanese EUC
+ '' : 'sjis', # Shift-JIS Japanese
+ '' : 'euckr', # Korean EUC
+ 'utf-8' : 'utf8', # Unicode (UTF-8)
+ '' : 'ucs2', # Unicode (UCS-2) <-- not allowed as
connection encoding
+ 'iso8859-1' : 'latin1', # ISO 8859-1 ECMA-94 Latin Alphabet No.1
+ 'iso8859-2' : 'latin2', # ISO 8859-2 ECMA-94 Latin Alphabet No.2
+ 'iso8859-9' : 'latin5', # ISO 8859-9 ECMA-128 Latin Alphabet No.5 =
ISO 8859-9 Turkishabet No.6
+ 'iso8859-13': 'latin7', # ISO 8859-13 Latin Alphabet No.7
+ 'iso8859-7' : 'greek', # ECMA-118 Latin/Greek = ISO 8859-7 Greek
+ 'iso8859-8' : 'hebrew', # ECMA-121 Latin/Hebrew = ISO 8859-8 Hebrew
+ 'koi8-r' : 'koi8r', # KOI8-R Relcom Russian
+ 'koi8-u' : 'koi8u', # KOI8-U Ukrainian
+ 'cp1250' : 'cp1250', # Windows CP1250 Central European
+ 'cp1251' : 'cp1251', # Windows CP1251 = Windows Cyrillic
+ 'cp1256' : 'cp1256', # Windows CP1256 = Windows Arabic
+ 'cp1257' : 'cp1257', # Windows CP1257 = Windows Baltic
+ 'cp850' : 'cp850', # DOS West European
+ 'cp852' : 'cp852', # DOS Central European
+ '' : 'swe7', # 7bit Swedish
+ '' : 'cp932', # SJIS for Windows Japanese
+ '' : 'eucjpms', # UJIS for Windows Japanese
+ '' : 'geostd8', # GEOSTD8 Georgian
+ '' : 'tis620', # TIS620 Thai
+ '' : 'armscii8', # ARMSCII-8 Armenian
+ '' : 'cp866', # DOS Russian
+ '' : 'keybcs2', # DOS Kamenicky Czech-Slovak
+ '' : 'macce', # Mac Central European
+ '' : 'macroman', # Mac West European
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8242 - trunk/gnue-common/src/datasources/drivers/sql/mysql,
jan <=