Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philotas/9973287962778de50398e4b93f622399 to your computer and use it in GitHub Desktop.
Save philotas/9973287962778de50398e4b93f622399 to your computer and use it in GitHub Desktop.
MAMP + Python-MySQLdb
1. Goto http://dev.mysql.com/downloads/mysql/
2. Select Platform: "Mac OS X"
3. Download mysql-5.5.11-osx10.6-x86.tar.gz
(Mac OS X ver. 10.6 (x86, 32-bit), Compressed TAR Archive)
4. Unzip it
5. Copy include folder into /Applications/MAMP/Library
6. Copy lib/* files into /Applications/MAMP/Library/lib
----
1. Goto http://sourceforge.net/projects/mysql-python/
2. Download MySQL-python-1.2.3.tar.gz
3. unzip it
----
1. virtualenv --no-site-package test
2. cd test/bin
3. source activate
4. lipo -remove x86_64 ./python -output ./python
----
1. export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib
2. export ARCHFLAGS='-arch i386'
----
1. cd MySQL-python-1.2.3
2. vim setup_posix.py
3. search mysql_config.path
4. set the value to /Applications/MAMP/Library/bin/mysql_config
5. save and exit
6. python setup.py install
----
import _mysql
db = _mysql.connect(unix_socket="/Applications/MAMP/tmp/mysql/mysql.sock",db="mysql",user="root",passwd="root")
db.query("select version()")
result = db.use_result() / result = db.store_result()
result.fetch_row()
result.fetch_row(result.num_rows())
result.fetch_row()
result.data_seek(0)
result.fetch_row()
----
If import _mysql Got Reason: image not found
try:
export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib
export ARCHFLAGS='-arch i386'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment