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 install
I'm giving the full path for python to make sure it does not use the MacPorts one.
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.
PlanetMySQL Voting: Vote UP / Vote DOWN