Mercurial > p > mysql-python > mysqldb-2
comparison MySQLdb/connections.py @ 1:e51bc565a529 MySQLdb
Merged fixes from 1.2 branch
author | adustman |
---|---|
date | Fri, 07 Apr 2006 02:44:04 +0000 |
parents | e48810735f11 |
children | b5a377255eea |
comparison
equal
deleted
inserted
replaced
0:e48810735f11 | 1:e51bc565a529 |
---|---|
114 | 114 |
115 ssl | 115 ssl |
116 dictionary or mapping, contains SSL connection parameters; | 116 dictionary or mapping, contains SSL connection parameters; |
117 see the MySQL documentation for more details | 117 see the MySQL documentation for more details |
118 (mysql_ssl_set()). If this is set, and the client does not | 118 (mysql_ssl_set()). If this is set, and the client does not |
119 support SSL, UnsupportedError will be raised. | 119 support SSL, NotSupportedError will be raised. |
120 | 120 |
121 local_infile | 121 local_infile |
122 integer, non-zero enables LOAD LOCAL INFILE; zero disables | 122 integer, non-zero enables LOAD LOCAL INFILE; zero disables |
123 | 123 |
124 There are a number of undocumented, non-standard methods. See the | 124 There are a number of undocumented, non-standard methods. See the |
251 return atoi(info.split()[-1]) | 251 return atoi(info.split()[-1]) |
252 else: | 252 else: |
253 return 0 | 253 return 0 |
254 | 254 |
255 def set_character_set(self, charset): | 255 def set_character_set(self, charset): |
256 """Set the connection character set to charset.""" | 256 """Set the connection character set to charset. The character |
257 try: | 257 set can only be changed in MySQL-4.1 and newer. If you try |
258 super(Connection, self).set_character_set(charset) | 258 to change the character set from the current value in an |
259 except AttributeError: | 259 older version, NotSupportedError will be raised.""" |
260 if self._server_version < (4, 1): | 260 if self.character_set_name() != charset: |
261 raise UnsupportedError, "server is too old to set charset" | 261 try: |
262 if self.character_set_name() != charset: | 262 super(Connection, self).set_character_set(charset) |
263 except AttributeError: | |
264 if self._server_version < (4, 1): | |
265 raise NotSupportedError, "server is too old to set charset" | |
263 self.query('SET NAMES %s' % charset) | 266 self.query('SET NAMES %s' % charset) |
264 self.store_result() | 267 self.store_result() |
265 self.string_decoder.charset = charset | 268 self.string_decoder.charset = charset |
266 self.unicode_literal.charset = charset | 269 self.unicode_literal.charset = charset |
267 | 270 |
268 def set_sql_mode(self, sql_mode): | 271 def set_sql_mode(self, sql_mode): |
269 """Set the connection sql_mode. See MySQL documentation for | 272 """Set the connection sql_mode. See MySQL documentation for |
270 legal values.""" | 273 legal values.""" |
271 if self._server_version < (4, 1): | 274 if self._server_version < (4, 1): |
272 raise UnsupportedError, "server is too old to set sql_mode" | 275 raise NotSupportedError, "server is too old to set sql_mode" |
273 self.query("SET SESSION sql_mode='%s'" % sql_mode) | 276 self.query("SET SESSION sql_mode='%s'" % sql_mode) |
274 self.store_result() | 277 self.store_result() |
275 | 278 |
276 def show_warnings(self): | 279 def show_warnings(self): |
277 """Return detailed information about warnings as a | 280 """Return detailed information about warnings as a |