For any of you who both run Windows and use MySQL as your database backend, you may have found MySQLdb already.  You may also notice that there is no release for Python 2.6.x on the page.  That struck me as odd, since Python has moved into the 2.6 days near the end of 2008, and then shortly thereafter, they announced and release Python 3.  Why hasn’t MySQLdb caught up?

So I’m stuck with Python 2.5.4?  you say.  Not quite– If you run Linux, just compile the MySQLdb source on your 2.6 version of Python, or if you run windows (and heaven knows it’s hell trying to compile anything from source on a windows machine) then you should just download this obscure 2.6 release of MySQLdb.  The only reason I know about it is because I’m on the mod_python mailing list, and someone had a question about the missing 2.6 version.

So that you’re properly warned, Python 2.6 deprecated the Sets module from ImmutableSets, which gives a warning when MySQLdb gets fired up.  MySQLdb works just fine still, but it’ll likely need some work to become compatible with Python 3.

Tagged with:

24 Responses to Python 2.6 & MySQL

  1. Pete says:

    Thanks for this. I was wondering what to do about talking to MySQL.

  2. Geoff says:

    You rock. This was about to suck. :)

  3. Awesome. I was almost there but gave up after seeing this:

    running build_ext
    building ‘_mysql’ extension
    error: Unable to find vcvarsall.bat

    Why the hell does Python 2.6 have to be such a pain…

    • That sucks… if only Windows and every flavor of Linux had a mutual equivalent to the Synaptic Package Manager as found in Ubuntu..

    • Hiro2k says:

      Yeah I got this far as well trying to compile. I downloaded Mingw but that didn’t have the vcvarsall.bat, so I was started download MSVC++ 2008 and I saw this post.

      Thanks to whoever made that executable!

  4. […] Artículo original en inglés […]

  5. Bob Koure says:

    I can move to 2.6.

  6. David Goadby says:

    This took some finding for sure! I needed 2.6 for HTTP time-outs and was stuck because of MySQLdb. Now there is hope. It’s about time MySQL was formally included as a module.

  7. Lidy says:

    Thanks! I’ve decided to use python to build my system’s thesis … i think it will help me a lot.

  8. Ivan says:

    Thank you!!!!!

  9. trevor says:


  10. Gaël says:

    Another thank you to you !!!

  11. Manoj says:

    Thanks, this really helped!

  12. vittorio says:

    Ehi, good post!
    I can use mysql in my python 2.6 on windows with this “obscure” :-)

  13. Ari says:

    Thanks for this info!
    I was getting a bit frustrated when building the package from sources, under Windows, wouldn’t work…

  14. Piotr says:

    Thank you. Now it works :-)

  15. David says:

    Just a note in case some of you run into problems: 32-bit version of python is required

    • Tim says:

      Yes, that is a problem which plagues almost every flagship python module for Windows platforms. 64-bit python is definitely not ready for Windows developers. Another major problem package is PIL, the imaging library!

  16. Alviss says:

    You’re a lifesaver.

  17. Fridi says:


    I installed python26 (32bit) and the ‘obscure’ mySQL release…but when importing that via import MySQLdb it says:
    “ImportError: DLL load failed: %1 is no valid win32 application.”

    Want to use it with maya2012 64bit…maybe THIS is the issue?

    • Tim says:

      I’m not familiar with that specific error, but it makes me think that perhaps MySQL itself isn’t properly installed? MySQLdb is an adapter, “bindings” for communicating with the MySQL installation on the machine.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>