MySQLdb-python on OS X (10.5)

November 13th, 2008 § 0

In an effort to setup Django for a project I’m working on (more on that another day), I ran into some issue installing MySQL-python (version 1.2.2). Googling around I found a few discussions regarding it. After fiddling around with it for a while, I managed to get it going.

Here’s how:

(Assuming you have MySQL installed and have the /usr/local/mysql/bin in your path.)
Comment out the following three lines in <MySQL-python location>/_mysql.c, as such:

/*
#ifndef uint
#define uint unsigned int
#endif
*/

Now, run the build and install commands:

python setup.py build
sudo python setup.py install

We can do a quick test:

python
Python 2.5.1 (r251:54863, Jul 23 2008, 11:00:16)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import MySQLdb
/Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg/_mysql.pyc, but /Applications/MySQL-python-1.2.2 is being added to sys.path
import sys, pkg_resources, imp
>>> conn = MySQLdb.connect(host = “HOST”, user = “USER”, passwd = “PASS”, db = “DATABASE”)
>>> cursor = conn.cursor()
>>> cursor.execute(“SELECT VERSION()”)
1L
>>> row = cursor.fetchone()
>>> row[0]
’5.0.67′
>>> cursor.close()
>>> conn.close()

Now sure if that warning will have implications later; doesn’t seem like it but you never know.

  • Share/Bookmark

Tagged: , ,

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

§ Leave a Reply

What's this?

You are currently reading MySQLdb-python on OS X (10.5) at life of a gizmo.

meta