Home > Python, Tutorials > MySQLdb in Cygwin

MySQLdb in Cygwin

I use Windows XP on all of my 4 primary machines (work, work, laptop & home). The only reason I like Windows XP is because it holds PuTTY windows so nicely and allows me to Alt-Tab between them. No Linux distro or Window Manager has ever really had the Alt-Tab experience that Windows XP provides.

sshv2-putty-window

The main problem with XP is that to do anything remotely useful with it you need a decent terminal/shell. I love rxvt/bash and the best rxvt you can find for Windows is via cygwin. Out of the box cygwin is an ugly brute - bash in cmd.exe != a real term.

cygwin_shell

Install rxvt via cygwin, then add some Consolas fonts (from Windows Vista) and edit your .Xdefaults to get a much nicer term.

rxvt

Download a sadistic editor. Drop in a beautiful colour-scheme (brookstream). You now have a sweet shell and editor.

gvim

Install Python via cygwin and away you go.

Perfection?

I was attempting to connect to a remote MySQL DB when my sweet setup failed me.

Nothing in cygwin's repository could help -- there is basically no support in cygwin for MySQL (odd). There is tons of support for Python and Postgres, so this MySQL FAIL surprised me.

After an entire morning of Googleing it turns out the people at Cygwin Ports have solved this problem. For the sake of your sanity follow these simple steps to get Cygwin + Python + MySQL working.

  1. Follow the steps above to create a sweet cygwin development environment.
  2. Follow the overly convoluted steps to enable cygwin ports in your setup.exe
  3. Install the following package "python-mysql" including the crucial dependancy "libmysqlclient-devel"
  4. Test your setup

python

Rejoice?

This process has saved you the experience of python eggs, installing gcc, compiling anything from source and best of all it just works.

Enjoy!

- Graver

One last note - if you have ever found a slick PNG that you wanted as an ICO (for Windows XP) check out this online converter site!

Categories: Python, Tutorials Tags:

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

  1. No comments yet.
  1. No trackbacks yet.