Roundup Tracker - Issues

Issue 1096031

classification
MySQL backend doesn't handle options consistently
Type: Severity: normal
Components: None Versions:
process
Status: closed fixed
:
: : bruceguenter, jlgijsbers, richard
Priority: normal :

Created on 2005-01-04 20:55 by bruceguenter, last changed 2005-01-13 05:00 by richard.

Files
File name Uploaded Description Edit Remove
back_mysql.patch bruceguenter, 2005-01-04 20:58 MySQL backend patch
back_mysql2.patch bruceguenter, 2005-01-06 21:02 Second MySQL backend patch.
Messages
msg1794 Author: [hidden] (bruceguenter) Date: 2005-01-04 20:55
If the MySQL socket file is anything other than the
compiled-in default, the MySQL backend fails.  The
attached patch fixes it for me, but is not necessarily
the best path.  The preferred option would be to have
the backend read the .my.cnf config file like all other
MySQL applications do (through the mysql_options C
function) but I can't see how to access that through
MySQLdb at the moment.

msg1795 Author: [hidden] (richard) Date: 2005-01-05 22:11
Logged In: YES 
user_id=6405

What format is the .my.cnf file? Perhaps we could parse it? 
 
msg1796 Author: [hidden] (bruceguenter) Date: 2005-01-06 20:49
Logged In: YES 
user_id=547942

I have been searching the docs, and just noticed that the
MySQLdb.connect function will do the config file reading
*if* it is passed either a read_default_file or
read_default_group option.  Unfortunately, those options are
the last two specified for the function.  This can be done
in the config file by setting:

MYSQL_DATABASE = ( MYSQL_DBHOST, MYSQL_DBUSER,
MYSQL_DBPASSWORD, MYSQL_DBNAME, None, None, None, None,
None, None, None, None, 'roundup' )

Since all those Nones are easy to mess up (easy to get the
wrong numberor the API for MySQLdb.connect could change),
you could make MYSQL_DATABASE be a dictionary, and drop the
other MYSQL_* configuration options:

MYSQL_DATABASE = {
  host:'localhost',
  user:'roundup',
  passwd:'asdhfakshdfk',
  db:'roundup',
  read_default_group:'roundup',
}

I'll work on a patch to allow for this.  The most important
part, however, is that all the connects need to use the same
options (right now only one of them uses MYSQL_DATABASE, the
rest all break).
msg1797 Author: [hidden] (bruceguenter) Date: 2005-01-06 21:01
Logged In: YES 
user_id=547942

I'm attaching another patch to unify the configuration in
back_mysql.py to use a single "MYSQL" dictionary.  This will
break existing sites that use MYSQL_DATABASE, and as such is
likely unsuitable for inclusion in a minor upgrade.
msg1798 Author: [hidden] (jlgijsbers) Date: 2005-01-06 21:41
Logged In: YES 
user_id=469548

I think one can read .my.cnf using the read_default_file to
MySQLdb.connect():

MySQLdb.connect(read_default_file="~/.my.cnf")
msg1799 Author: [hidden] (jlgijsbers) Date: 2005-01-06 22:17
Logged In: YES 
user_id=469548

Uhm, doh. Bruce already said that. Move along, nothing to
see here. ;)
msg1800 Author: [hidden] (richard) Date: 2005-01-13 05:00
Logged In: YES 
user_id=6405

I have rolled some code into the maint-0-8 branch (and HEAD) 
implementing handling of this. The unit tests run, but I've not tried to 
actually *use* a .my.cnf file, so I don't know if that part works.

Bruce, I would appreciate if you could verify that it works with a .my.cnf 
file.
History
Date User Action Args
2005-01-04 20:55:27bruceguentercreate