#!/usr/bin/python
# -*- coding: UTF-8 -*-
import MySQLdb
# 打开数据库连接
db = MySQLdb.connect("localhost","testuser","test123","TESTDB" )
# 使用cursor()方法获取操作游标
cursor = db.cursor()
# 使用execute方法执行SQL语句
cursor.execute("SELECT DATE_FORMAT(NOW(),'%Y-%m-%d')")
# 使用 fetchone() 方法获取一条数据
date_now = cursor.fetchone()
print "Date now : %s " % date_now
# 关闭数据库连接
db.close()