Home |  MySQL Buzz |  FAQ |  Feeds |  Submit your blog feed |  Feedback |  Archive |  Aggregate feed RSS 2.0 English Deutsch Español Français Italiano 日本語 Русский
MySQL, Python and MacOS X 10.6 (Snow Leopard)
+2 Vote Up -0 Vote Down

This has been already mentioned in on a few blogs, but I thought it would be good to post here too. Note: this is not using MacPorts!

To get MySQL and Python going on MacOS X 10.6 you need the following:


Install MySQL using the tar ball and make sure you get it up and running.

Compile MySQL-python (leave out setting the $PATH when it's already done):

shell> PATH="/usr/local/mysql/bin:$PATH"
shell> tar xzf MySQL-python-1.2.3c1.tar.gz
shell> cd MySQL-python-1.2.3c1
shell> ARCHFLAGS="-arch x86_64" /usr/bin/python setup.py build
shell> /usr/bin/python setup.py install

I'm giving the full path for python to make sure it does not use the MacPorts one.
EDIT 2009-09-24: If it can't find mysql_config, you did not set your path correctly, but you can update the setup_posix.py fine of MySQL-Python and change it to something like this (as seen on our forums):


mysql_config.path = "/usr/local/mysql-5.1.39-osx10.5-x86_64/bin/mysql_config"

Here a test script test_mysql.py:

import MySQLdb

if __name__ == "__main__":
db = MySQLdb.connect(host="localhost",
user="root",db="test")
cursor = db.cursor()
cursor.execute("SHOW ENGINES")

for row in cursor.fetchall():
print row

cursor.close()
db.close()

Run the above script like:


shell> /usr/bin/python test_mysql.py

It should output the available storage engines.

Votes:

You must be logged in with a MySQL.com account to vote on Planet MySQL entries. More information on PlanetMySQL voting.

Planet MySQL © 1995-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Sun Microsystems, Inc. and does not
necessarily represent the opinion of Sun Microsystem, Inc. or any other party.