@@ -426,14 +426,14 @@ def __init__(self, host="localhost", user=None, passwd="",
426
426
init_command: Initial SQL statement to run when connection is established.
427
427
connect_timeout: Timeout before throwing an exception when connecting.
428
428
ssl: A dict of arguments similar to mysql_ssl_set()'s parameters. For now the capath and cipher arguments are not supported.
429
- read_default_group: Not supported
429
+ read_default_group: Group to read from in the configuration file.
430
430
compress; Not supported
431
431
named_pipe: Not supported
432
432
"""
433
433
434
434
435
- if read_default_group or compress or named_pipe :
436
- raise NotImplementedError , "read_default_group, compress and named_pipe arguments are not supported"
435
+ if compress or named_pipe :
436
+ raise NotImplementedError , "compress and named_pipe arguments are not supported"
437
437
438
438
if ssl and (ssl .has_key ('capath' ) or ssl .has_key ('cipher' )):
439
439
raise NotImplementedError , 'ssl options capath and cipher are not supported'
@@ -448,13 +448,22 @@ def __init__(self, host="localhost", user=None, passwd="",
448
448
v = ssl [k ]
449
449
setattr (self , k , v )
450
450
451
+ if read_default_group and not read_default_file :
452
+ if sys .platform .startswith ("win" ):
453
+ read_default_file = "c:\\ my.ini"
454
+ else :
455
+ read_default_file = "/etc/my.cnf"
456
+
451
457
if read_default_file :
458
+ if not read_default_group :
459
+ read_default_group = "client"
460
+
452
461
cfg = ConfigParser .RawConfigParser ()
453
462
cfg .read (os .path .expanduser (read_default_file ))
454
463
455
464
def _config (key , default ):
456
465
try :
457
- return cfg .get ("client" ,key )
466
+ return cfg .get (read_default_group ,key )
458
467
except :
459
468
return default
460
469
0 commit comments