#!/usr/bin/python
import MySQLdb
# 打开数据库连接
db = MySQLdb.connect("localhost","testuser","test123","TESTDB" )
#打开游标
cursor = db.cursor()
# 执行数据库查询
cursor.execute("SELECT * from users")
# 获取结果集的第一行
data = cursor.fetchone()
print "Database version : %s " % data
# 关闭连接
db.close()