Reputation: 2796
I been working on finding out how to install MySQLdb module for Python on Mac. And all pathes finally come cross to have MySQL installed since there is a mysql_config needed for the module. But I don't understand why it has to be needed?
MySQLdb suppose to be a client module for the client who wants to connect to the server. But now I have to first install a server on the client in order to connect to another server?
Upvotes: 1
Views: 460
Reputation: 3520
Just to complete the fine answers, here's a small how-to for installing MySQLdb on MacOS X 10.6. This was posted on my blog and you might check that out for maybe more info (and links as I'm a new user on stackoverflow, can only add one).
I'm not covering the installation of MySQL, but when you've done so, here's how you install MySQLdb.
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
There is currently work done on MySQL Connector/Python. The is a pure Python implementation of the MySQL protocol so you don't need to install any MySQL software or compile to get you going.
Upvotes: 3
Reputation: 600059
Just to clarify what the other answerers have said: you don't need to install a MySQL server, but you do need to install the MySQL client libraries. However, for whatever reasons, MySQL don't make a separate download available for just the client libraries, as they do for Linux.
Upvotes: 1
Reputation: 85125
MySQLdb is not a client module per se. It is a wrapper or interface between Python programs and the standard MySQL client libraries. MySQLdb conforms to the Python standard DB API. There are other conforming adapters implemented for other database managers. Using the common API makes it much easier to write database-independent code in Python; the adapters handle (much of) the messy differences among the various database client libraries. Thus, you do need to install MySQL client libraries; there are several ways to do this: the easiest options are probably downloading prebuilt libraries from mysql.com or you can use a package manager, like MacPorts, to install them and other dependencies.
Upvotes: 1
Reputation: 130004
What it needs is the client library and headers that come with the server, since it just a Python wrapper (which sits in _mysql.c
; and DB-API interface to that wrapper in MySQLdb
package) over original C MySQL API.
Upvotes: 1
Reputation: 766
I'm not sure about the specifics of MySQLdb, but most likely it needs header information to compile/install. It uses the location of mysql_config to know where the appropriate headers would be. The MySQL Gem for Ruby on Rails requires the same thing, even though it simply connects to the MySQL server.
Upvotes: 1