I found problem with proper defining default client/connection character set used within MySQLdb 1.2.0 and MySQL 4.1.19. The settings I put in my.ini doesn't seem to work (although mysql.exe properly recognizes them).
The workaround I found is to manually describe path to the my.ini file while using 'connect' function, but it doesn't satisfy me at all. So the question is where the MySQLdb module seeks for default my.ini file?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The mysql command line client, as far as I know, reads ~/.my.cnf automatically. It might also read the system-wide my.cnf as well; check the documentation. The C API does not do this on it's own, so MySQLdb does not do this either. Set read_default_file on connect() or subclass the connection object to do it automatically.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is total mess with config files. Newest MySQL uses by default it's own directory (eg. c:\mysql\my.ini), but allows defining the path to the file during service startup. This (default) location is by no means accepted by mysql.exe client, which looks for my.cnf or my.ini file in c:\ or c:\windows directory. Neither of these locations is accepted by MySQLdb, although it implicitly uses mysql_options() functions with states:
"MYSQL_READ_DEFAULT_FILE Read options from the named option file instead of from my.cnf."
Therefore I believe it should be something like 'default' my.cnf file location, but after spending couple of hours trying to find it, I think I give up. This is really strange because MySQL 4.0+MySQLdb 1.0 worked perfectly ok.
Of course using read_default_file or subclassing connect class is simple solution, especially with new projects, but due to its incompability it collides with many other efforts, ie. object-relational mappers like SQLObject with it's nice URI's.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh well. Location of that file is platform-dependent, as far as I know, but you can patch MySQLdb to do it with one line of code. In MySQLdb.connections.Connection.init, add a line like this:
Personally I think the docs are wrong or misleading. You might want to put in a comment asking for clarification. Maybe it only reads from the default file if read_default_group is set; my testing seems to support this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found problem with proper defining default client/connection character set used within MySQLdb 1.2.0 and MySQL 4.1.19. The settings I put in my.ini doesn't seem to work (although mysql.exe properly recognizes them).
The workaround I found is to manually describe path to the my.ini file while using 'connect' function, but it doesn't satisfy me at all. So the question is where the MySQLdb module seeks for default my.ini file?
The mysql command line client, as far as I know, reads ~/.my.cnf automatically. It might also read the system-wide my.cnf as well; check the documentation. The C API does not do this on it's own, so MySQLdb does not do this either. Set read_default_file on connect() or subclass the connection object to do it automatically.
There is total mess with config files. Newest MySQL uses by default it's own directory (eg. c:\mysql\my.ini), but allows defining the path to the file during service startup. This (default) location is by no means accepted by mysql.exe client, which looks for my.cnf or my.ini file in c:\ or c:\windows directory. Neither of these locations is accepted by MySQLdb, although it implicitly uses mysql_options() functions with states:
"MYSQL_READ_DEFAULT_FILE Read options from the named option file instead of from my.cnf."
Therefore I believe it should be something like 'default' my.cnf file location, but after spending couple of hours trying to find it, I think I give up. This is really strange because MySQL 4.0+MySQLdb 1.0 worked perfectly ok.
Of course using read_default_file or subclassing connect class is simple solution, especially with new projects, but due to its incompability it collides with many other efforts, ie. object-relational mappers like SQLObject with it's nice URI's.
Oh well. Location of that file is platform-dependent, as far as I know, but you can patch MySQLdb to do it with one line of code. In MySQLdb.connections.Connection.init, add a line like this:
or since you have Windows:
http://dev.mysql.com/doc/mysql/en/mysql-options.html
Personally I think the docs are wrong or misleading. You might want to put in a comment asking for clarification. Maybe it only reads from the default file if read_default_group is set; my testing seems to support this.