I'm having a problem with encoding info. I've researched this problem and tried all the solutions I could, but the problem persists. Here's what I'm running:
Mac OSX 10.4.6 (ppc)
MySQLdb 1.2.1
MySQL 4.1.18
Python 2.3 (OEM install)
I'm running a simple program to get the server version (I'm still learning all this). Here it is:
Traceback (most recent call last):
File "server_version.py", line 10, in ?
cursor.execute("SELECT VERSION()")
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/MySQLdb/cursors.py", line 146, in execute
query = query.encode(charset)
LookupError: unknown encoding: latin1_swedish_ci
I originally installed MySQL 4.1.9, which should have this bug fixed anyway, but to make sure I installed 4.1.18. However, when I run MySQLdb.get_client_info(), it still says 4.1.9.
I'd appreciate any thoughts on this problem. I've been working on it for hours and I'm ready to pull my hair out.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2006-05-04
Thanks again. That was an extemely simple thing I should have done long ago. Guess it ruins my street cred, huh?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The other thing you may want to consider: Do you really want to use latin1_swedish_ci as your collation? You may want to think about changing the default encoding for your server/database/tables, unless of course you actually want a Swedish collation, but the odds are against that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2006-05-04
I did rebuild MySQLdb after the fact. I went into the site-packages folder and removed the MySQLdb folder, _mysql_exceptions.py, _mysql_exceptions.pyc, and _mysql.so.
Are there any other files I need to look for? When I reinstalled MySQL, I made sure I removed the /usr/local/mysql folder first. If there are any other places I should look for stuff that needs to be removed, let me know. I don't know if there are any Mac-specific files hidden away somewhere.
As for the encoding, that's the default (as I'm sure you know - I'm just learning this, so it's easier for me to spell everything out :) ), and according to the MySQL documentation, they say it should be good enough for all United States/Western Europe uses. If there's a better kind, please let me know.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2006-05-04
OK, I got it to work. Thanks for your help. After reading your response, I decided to dig deeper into the Mac side of things, and found some extra Mac stuff that needed to be removed. For anyone with a similar problem, you need to go into /Library/Receipts and remove all MySQL packages before reinstalling, or it will upgrade, not install, and therefore keep all the old libraries. Also, in the MySQLdb-python-1.2.1_p2 folder, I emptied out the build folder. All I know is that the simple script I ran now works, and MySQLdb.get_client_info() now returns 4.1.18 like it should.
On another note, in order for setup.py to run on my computer, I had to edit a line. In the mysql_config function, I had to change this line:
f = popen("mysql_config --%s" % what)
to this line:
f = popen("/usr/local/mysql/bin/mysql_config --%s" % what)
Just a little something for those having some OSX installation issues.
Again, thanks for your help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh yeah, getting rid of build is probably what fixed it, since distutils only looks at the timestamps on the source and object files and not the libraries.
The better way to fix your mysql_config problem is to make sure mysql_config is on your PATH. If you are using bash or sh-type shell:
$ export PATH="$PATH:/usr/local/mysql/bin"
or else add /usr/local/mysql/bin to your system PATH (probably in /etc/profile). No need to modify setup.py.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm having a problem with encoding info. I've researched this problem and tried all the solutions I could, but the problem persists. Here's what I'm running:
Mac OSX 10.4.6 (ppc)
MySQLdb 1.2.1
MySQL 4.1.18
Python 2.3 (OEM install)
I'm running a simple program to get the server version (I'm still learning all this). Here it is:
! /usr/bin/python
import MySQLdb
conn = MySQLdb.connect (host="localhost",
user="root",
passwd="",
db="test")
cursor = conn.cursor()
cursor.execute("SELECT VERSION()")
row = cursor.fetchone()
print "server version", row[0]
cursor.close()
conn.close()
When I try to run it, I get this error:
Traceback (most recent call last):
File "server_version.py", line 10, in ?
cursor.execute("SELECT VERSION()")
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/MySQLdb/cursors.py", line 146, in execute
query = query.encode(charset)
LookupError: unknown encoding: latin1_swedish_ci
I originally installed MySQL 4.1.9, which should have this bug fixed anyway, but to make sure I installed 4.1.18. However, when I run MySQLdb.get_client_info(), it still says 4.1.9.
I'd appreciate any thoughts on this problem. I've been working on it for hours and I'm ready to pull my hair out.
Thanks again. That was an extemely simple thing I should have done long ago. Guess it ruins my street cred, huh?
Did you rebuild MySQLdb after installing MySQL-4.1.18? I'm guessing not, and you have static linking.
The other thing you may want to consider: Do you really want to use latin1_swedish_ci as your collation? You may want to think about changing the default encoding for your server/database/tables, unless of course you actually want a Swedish collation, but the odds are against that.
I did rebuild MySQLdb after the fact. I went into the site-packages folder and removed the MySQLdb folder, _mysql_exceptions.py, _mysql_exceptions.pyc, and _mysql.so.
Are there any other files I need to look for? When I reinstalled MySQL, I made sure I removed the /usr/local/mysql folder first. If there are any other places I should look for stuff that needs to be removed, let me know. I don't know if there are any Mac-specific files hidden away somewhere.
As for the encoding, that's the default (as I'm sure you know - I'm just learning this, so it's easier for me to spell everything out :) ), and according to the MySQL documentation, they say it should be good enough for all United States/Western Europe uses. If there's a better kind, please let me know.
OK, I got it to work. Thanks for your help. After reading your response, I decided to dig deeper into the Mac side of things, and found some extra Mac stuff that needed to be removed. For anyone with a similar problem, you need to go into /Library/Receipts and remove all MySQL packages before reinstalling, or it will upgrade, not install, and therefore keep all the old libraries. Also, in the MySQLdb-python-1.2.1_p2 folder, I emptied out the build folder. All I know is that the simple script I ran now works, and MySQLdb.get_client_info() now returns 4.1.18 like it should.
On another note, in order for setup.py to run on my computer, I had to edit a line. In the mysql_config function, I had to change this line:
f = popen("mysql_config --%s" % what)
to this line:
f = popen("/usr/local/mysql/bin/mysql_config --%s" % what)
Just a little something for those having some OSX installation issues.
Again, thanks for your help.
Oh yeah, getting rid of build is probably what fixed it, since distutils only looks at the timestamps on the source and object files and not the libraries.
The better way to fix your mysql_config problem is to make sure mysql_config is on your PATH. If you are using bash or sh-type shell:
$ export PATH="$PATH:/usr/local/mysql/bin"
or else add /usr/local/mysql/bin to your system PATH (probably in /etc/profile). No need to modify setup.py.