MySQL + Python + Win32

Jeff Bauer jbauer at
Mon Dec 11 16:28:44 CET 2000

Recently a friend with no Python nor MySQL experience
wanted to try using both on a Win32 platform.  After
telling him it should work fine I decided to check it
out -- since almost all my experience with MySQL has 
been on Linux/Solaris platforms.  The following is a
brief portion of the reply I sent him.


This looks pretty straightforward.  I installed Python2.0, 
MySQL 3.23.28-gamma, and the
files onto an NT4.0 system.

I used Gerhard's win32 MySQLdb Python interface, compiled
from Andy Dustman's sources:

Don't forget to run "python install" from the
MySQL-python-0.3.0 directory.

First, I test it against a known Unix database server.

Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> connection = MySQLdb.connect(host='domitian', db='fhc', user='jbauer', passwd='XXX')
>>> c = connection.cursor()
>>> c.execute("select ID, LNAME from CLIENT")
>>> for r in c.fetchall():
...     print r[0], r[1]
024123 Adelson
019868 Akers
026959 Akers
011502 Ambrose
032352 Anderson

Next, I try connecting to the local NT machine:

>>> ntconn = MySQLdb.connect(host='albatross', db='mysql', user='root')
>>> c = ntconn.cursor()
>>> c.execute("select * from User")
>>> for row in c.fetchall():
...     print row
('localhost', 'root', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y',
'Y', 'Y', 'Y', 'Y', 'Y')
('%', '', '', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N',
'N', 'N', 'N')
('localhost', '', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y',
'Y', 'Y', 'Y', 'Y')
('%', 'root', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y',
'Y', 'Y', 'Y')

Everything looks peachy. Good Luck!


More information about the Python-list mailing list