MySQLdb (Python module) on OSX
I’m working on a database for our CoalHMM analysis results. Right now, I’m playing around with different database designs, so I want to play around with the database on my local machine rather than our shared server.
I used to just do this on Linux, but this is the first time I’m playing with MySQL on OS X.
Installing MySQL was pretty painless as you can download a binary package for it.
MySQLdb, the Python module I use to access the database, is a different matter, however. I couldn’t find any binary packages and the source distribution doesn’t compile out of the box.
Luckily, I am not the first to want to use MySQLdb on a Mac, and a bit of googling found this page.
Worked like a charm, so now I am back to hacking data base designs.
–
84-103=-19
March 25th, 2009 at 11:20 pm
You can do “sudo easy_install MySQL-python” – this will install and build MySQLdb for you. If you haven’t heard about easy_install, check out http://peak.telecommunity.com/DevCenter/EasyInstall
A tip: Make sure to run the latest beta of MySQLdb – the current stable has a very nasty memory leak which basically leaks memory on each fetched result set…
March 26th, 2009 at 8:35 am
Thanks for the link, Amir. I had never heard about EasyInstall.
I’ll keep the memleak in mind. For the experiments I’m doing right now it isn’t so much an issue, but it will be when I get to the actual analysis. That wont run on my home computer, though, but I’ll check the MySQLdb installation on the grid where I run it before I start…
March 26th, 2009 at 5:14 pm
yes, easy_install is really great and supports a lot of modules.
I also prefer sqlalchemy to the raw mysqldb – it has a better syntax and is said to be a good example of python programming.
Elixir, a sqlalchemy plugin, is also great:
- http://elixir.ematia.de/trac/wiki/TutorialDivingIn
- http://bioinfoblog.it/2009/01/python-and-databases/
March 26th, 2009 at 5:34 pm
Thanks for the links, gioby, they look interesting.
I don’t really need any complex ORM, though, for this database. The data really is quite simple, there is just a hell of a lot of it.
I don’t want to tie myself to Python for the project either, since I need at least to access the data in both Python and R. Yeah, I know I can do that with rpy, but I am not the only one analysing the data, and for some weird reason, some of my statistician friends actually prefer R :)
March 6th, 2010 at 11:44 pm
This is great! Thanks for your article. I am starting development and this was a big help.