#!/usr/bin/python
# import MySQL module
import MySQLdb
# connect
db = MySQLdb.connect(host="localhost", user="root", passwd="#evan",
db="mysql")
# create a cursor
cursor = db.cursor()
# execute SQL statement
cursor.execute("SELECT * FROM user")
# get the resultset as a tuple
result = cursor.fetchall()
# iterate through resultset
for record in result:
print record[0] , "-->", record[1]
http://www.cnblogs.com/ceniy/archive/2010/08/31/1814066.html
http://www.cnblogs.com/rollenholt/archive/2012/05/29/2524327.html
http://alfred-long.iteye.com/blog/1935597