Archive for February 1st, 2009

Getting the python mysql connector working is a truly painful experience.  Alas, I can safe you a ton of time.

First thing to do.  Update the Python install on Mac OS X.  The default is 2.5.1.  For whatever reason this default install has all sorts of trouble when trying to compile MySQLdb.  I have no idea what or why and you won’t find this hint ANYWHERE.

To update, just get whatever 2.5.1+ version you want here.

Then, if you want Django to integrate with the install of XAMPP, follow this post.  It links to another post that takes you through the steps of getting MySQLdb compiled.  If you want to use MAMP, you just change the source of the symbolic links mentioned in the post (telling the compiler where to get mysql headers).

Oh, yes, you’ll need to get either the XAMPP or MAMP sources.  Both projects provide the sources of their packages.  You’ll need to get the ‘include’ directory from both and drop it into your MySQL directory.

Google for “xampp source” or “mamp source” and you’ll get to the latest versions.  I’d link to them here but you might read this post at a later time and get confused by my links.

No doubt you will have Google’d your eyeballs out trying to find fixes to this process.

here’s what doesn’t matter:

  • the discussion of 64bit mysql vs python 32 bit (when dealing with XAMPP or MAMP, those are both 32 bit mysql)
  • messing with the types.h file on your OS x
  • using macports or any exotic way of installing mysql

Now, the trickiest part is getting Django integrated in the XAMPP build of apache.  (The Django dev web server works fine if you’re just playing around).  I would NOT try to recompile XAMPP.  Instead, get the Django Stack from Bitnami, which is Apache, MySQL, Django and Python.  Yes, dev on your django dev and then port to this bitnami stack.    This entire stack can be moved if you need to, which is nice.

If you’re like me, coding is more fun that configuring.  I believe the above will get you coding and deploying faster than all the other recompile and bizarre options Linux gurus dish out.  I’d say for production/hard core sites, do the best compile you can.  For hacking up python, mysql and django, do the prepackaged stuff.

This method above has the advantage that everything is upgradeable without massive recompiles.  XAMPP provides an upgrade package when they do new builds.

Anyhoo… hope this saves you some time. Hack away.

Read Full Post »