Connecting Python 2.6.1 to MySQLdb

I am using Python 2.6.1 and I want to connect to MySQLdb, I installed mySQL on my system and I am trying to connect to MySQL-python-1.2.2.win32-py2.6 from http://www.codegood.com/ archives / 4 , but it doesn’t work when my application starts, it says that there is no module named MySQLdb

please anyone provided me with the correct setup for MySQLdb.

early

+4
source share
6 answers

The best setup for Windows I found:

http://www.codegood.com/downloads?dl_cat=2

EDIT: removed the original link (now this is an ad farm :()

+13
source

The module is hardly in your python search path ..

Check if this module is in your Python path ... On Windows ... you can find it in the registry

HKLM \ Software \ Python \ PythonCore \ 2.6 \ PYTHONPATH

Use caution when editing it ...

You can also programmatically change the Python Path as follows

import sys sys.path.append('somepath_to_the_module_you_wanted') import the_module_you_wanted 

Hope that helps

+4
source

I had this problem, and I realized that MySQLdb was imported incorrectly - it is case sensitive:

False: β†’> import mysqldb

Fix: β†’> import MySQLdb

Stupid mistake, but it cost me a few hours!

+2
source

overall, the (good) python modules provide a "setup.py" script that takes care of things like proper installation (google for "distutils python"). MySQLdb is a "good" module in this sense.

since you use windows, things can be a little more complicated. I assume that you have already installed MySQLdb as instructed, and it still gives this problem. what I would do is open the cmd.exe, cd window to the directory containing the "setup.py" script, and there is something like C: \ Python26 \ Python.exe setup.py install

if this does not work, then take the module somewhere else, possibly in the place where it is actively developing: http://sourceforge.net/projects/mysql-python/

0
source

Check out this mysql-python blog post: MySQL-python-1.2.3 beta released - dated March 2009. Looks like MySQLdb for Python 2.6 is still working ...

0
source

I went to a compiled binary, this is the best way to work with windows. A good source is maintained by someone. I wrote about this here earlier, because a few months after the lane I will forget how I decided it, and again I will look for Stack: / http://vangel.3ezy.com/archives/101-Python-2.4-2.5-2.6 -and-2.7-Windows-MySQLdb-python-installation.html

0
source

All Articles