Thanks to both of you for the help. I made several of the changes you suggested and am getting the results in the format I want, eg:
0 387 John Smith 1 453 Jane Smith 2 975 Joe Smithton My plan at this point is, in addition to printing the results of the query, to create a list with a matching index so the user can select a name and I can store the patient_ID to get other parts of their medical record. Does this sound reasonable? My code now looks like this: import MySQLdb def name_find(namefrag): conn = MySQLdb.connect(host = "localhost", user = "root", passwd = "Barron85", db = "meds") cursor = conn.cursor(MySQLdb.cursors.DictCursor) cursor.execute("SELECT patient_ID, firstname, lastname FROM demographics WHERE lastname LIKE '%s%%'" % (namefrag)) result = cursor.fetchall() for index, row in enumerate(result): print "%d %s %s %s" % (index, row["patient_ID"], row["firstname"], row["lastname"]) #create list here cursor.close() conn.close() Thanks again, Mike -- http://mail.python.org/mailman/listinfo/python-list