I'm trying to install MYSQLdb on a windows client. The goal is, from the Windows client, run a python script that connects to a MySQL server on a LINUX client. Looking at the setup code (and based on the errors I am getting when I try to run setup.py for mysqldb, it appears that I have to have my own version of MySQL on the windows box. Is there a way (perhaps another module) that will let me accomplish this? I need to have people on multiple boxes run a script that will interact with a MySQL database on a central server.
3 Answers
You don't need the entire MySQL database server, only the MySQL client libraries.

- 776,304
- 153
- 1,341
- 1,358
-
Which client libraries would I need? I tried downloading them but they didn't work. I double-checked and I ended up downloading the on for C code. I don't see one for python. I'm looking here, which might not be the right spot? http://dev.mysql.com/downloads/connector/ – WildBill May 11 '12 at 14:21
-
The C connector is the correct choice. You need to point the linker at the .lib files so it can't link against the DLL. – Ignacio Vazquez-Abrams May 11 '12 at 15:08
-
'setup.py install' still failed with that connector installed. It's looking for registry entries that this connector does not seem to be installing. – WildBill May 11 '12 at 20:25
you could use a pure python implementation of the mysql client like
pymysql
(can be used as a dropin-replacement for MySQLdb by callingpymysql.install_as_MySQLdb()
)MySql-Connector

- 67,110
- 10
- 163
- 162
-
MySql-Connector will run by itself and not require any local MySQL libraries? – WildBill May 11 '12 at 14:38
-
Yes, both libraries run without need for the mysql libraries to be installed. They're also [supported by sqlalchemy](http://docs.sqlalchemy.org/en/latest/dialects/mysql.html#module-sqlalchemy.dialects.mysql.pymysql) as dialects. – mata May 11 '12 at 14:46
It's been a long time since I wrote python db code for windows...but I think something like this should still work.
If you're running the client only on windows machines, install the pywin32 package. This should have an odbc module in it.
Using the windows control / management tools, create an odbc entry for either the user or the system. In that entry, you'll give the connection parameter set a unique name, then select the driver (in this case MySQL), and populate the connection parameters (e.g. host name, etc.) See PyWin32 Documentation for some notes on the odbc module in pywin32.
Also, see this post: Common ways to connect to odbc from python on windows.

- 1
- 1

- 1,598
- 8
- 8