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:
- Download MySQL MacOS X 10.5 (x86_64) tar ball. Yes, we download for v10.5 currently.
- Get a copy of MySQL-python
- Install the latest XCode tools found on the Snow Leopard CD under option installs or download it.
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 installI'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.