Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MySQLdb for Python 2.5

3 views
Skip to first unread message

Harold Trammel

unread,
Sep 29, 2006, 10:32:46 PM9/29/06
to
Hi everyone,

Does anyone know the status of a version of MySQLdb that will work with
Python 2.5? I will accept a workaround if you know one. Thanks in advance.

Harold Trammel

"Martin v. Löwis"

unread,
Sep 30, 2006, 4:08:19 AM9/30/06
to
Harold Trammel schrieb:

> Does anyone know the status of a version of MySQLdb that will work with
> Python 2.5?

AFAICT, MySQLdb 1.2.1 builds and works just fine.

Regards,
Martin

James Stroud

unread,
Sep 30, 2006, 6:08:08 AM9/30/06
to

I could not find a way around this requirement, but you will want to
manually add libz to your building with this version. This seems to be
how to do this when you run setup.py:

python setup.py -lz [other args] install

This is for mysqldb "MySQL-python-1.2.1_p2" (which I believe is the
latest).

I built this a few days ago and finally tested today and got this
terribly annoying (and apparently well documented) error:

[stacktrace clipped]
LookupError: unknown encoding: latin1_swedish_ci

My setup: python 2.5, very old mysql servers (C. 2003?), mysqldb
1.2.1_p2. It seems the problem is related to mysqldb, but I'm not sure.

I found the only real work-around here:

http://mail.python.org/pipermail/python-list/2006-July/350408.html

Its ugliness manifests in my code as such:


#######################################################################
# workaround function for problems with encoding
#######################################################################
def _csn(*args, **kwargs): return 'utf-8'

#######################################################################
# init_mysql()
#######################################################################
def init_mysql(the_db="some_db"):
adb = MySQLdb.connect(
host="sql.some.institute.edu",
# charset="utf8", # <-- our mysql servers too old for this
user="my_login",
passwd="pa55w0rd",
db=the_db
)
adb.character_set_name = instancemethod(_csn, adb, adb.__class__)
return adb


This fix passes some initial rudimentary tests. No guarantees on proper
handling of unicode. If you are using unicode, you may want to test it
thoroughly with this fix and report your results (preferably on this
comp.lang.python).


James

Jan Dries

unread,
Sep 30, 2006, 12:58:06 PM9/30/06
to pytho...@python.org

Does anyone know if Windows binaries for 2.5 are available somewhere?

Regards,
Jan

FatherAntox

unread,
Oct 5, 2006, 11:21:05 AM10/5/06
to

Hi Martin,

What is your setup as I am receiving a number of "Cannot open ..."
errors related to various msysql libraries and includes? I am running
in a Windows XP environment with MySQL 5.1. Thanks in advance.

Harold

"Martin v. Löwis"

unread,
Oct 5, 2006, 2:22:17 PM10/5/06
to FatherAntox
FatherAntox schrieb:

>> AFAICT, MySQLdb 1.2.1 builds and works just fine.
>>
>
> What is your setup as I am receiving a number of "Cannot open ..."
> errors related to various msysql libraries and includes? I am running
> in a Windows XP environment with MySQL 5.1. Thanks in advance.

I have been using Debian unstable. As I said, it built out of the box
(I actually built the Debian source package, adding 2.5 to the list
of target versions).

Regards,
Martin

0 new messages