Introduction
MySQL with Python In this tutorial you will learn how to use a widely used database management system called MySQL in Python. You do not need any previous knowledge of MySQL to use this tutorial, but there is a lot more to MySQL than covered in this short introductory tutorial.
- May 11, 2020 Download the mysql-connector-python-8.0.11-macos10.13.dmg file. It is an architecture Independent DMG file.Install the downloaded MySQL Connector Python by opening it and double-clicking the resulting.pkg file. Verifying MySQL Connector Python installation on macOS.
- Thanks to this line “Adding the Mac OS X 10.4 option from the Xcode installer (from the DVD) was also a necessary step”, I finally got working Python2.6 32bits with MySql5.1 32bits over Mac 10.6.7, using the driver MySQL-python1.2.3.
- Oct 31, 2008 This is because the coders behind MySQL-python have failed to fix a very simple bug in types.h (1808476 - '#define of uint breaks compiling on Mac OS X 10.5'). However, you can easily fix it yourself: Look for a reference to types.h in the terminal.
Just a quick note on getting MySQL-python (aka
import MySQLdb
) 1.2.3c1 (the current latest version) to build and install on Mac OS X, because I hit something that I didn’t see mentioned in a number of similar posts.Here are some links that discuss getting MySQL-python to build on Mac OS X:
![Mysql For Python Mac Mysql For Python Mac](/uploads/1/1/8/9/118943501/232423057.jpg)
What follows are the steps (slightly different) that I needed to get MySQL-python to install.
How To Install MySQL-Python On Mac OS X
Failed Building Wheel For Mysql-python Mac
- My SetupThough I am using ActivePython, the issues should be the same for a Python from python.org.
- Download and install MySQL ‘pkg’ format install for Mac OS X. For me this was the “Mac OS X 10.5 x86″ package:
mysql-5.1.34-osx10.5-x86.dmg
The following might work: - Download the latest MySQL-python package.
- Build it.For me this failed as follows:I didn’t see this mentioned in others’ post on this. I suspect they may not have hit this because they were building against the system Python (in /usr/bin/python, /System/Library/Frameworks/Python.framework/Versions/Current) which may have some tweaks to just handle this.In any case the problem here is that my Python install (ActivePython 2.6) is a universal build (including i386 and ppc). By default distutils (the library behind
python setup.py build
) tries to build binary Python extensions for all the same architectures. However, the MySQL you just installed is only for x86 so it borks.The fix is to use the ARCHFLAGS environment variable that distutils will pick up on to only build for your architecture: - Install it.