#/usr/bin/env python
#coding:utf-8
import re
import MySQLdb
import time
while True:
start_time = raw_input("\033[33m输入开始日期:\033[0m")
m = re.match('\d{4}-\d{2}-\d{2}',start_time)
if m > 0:
end_time = raw_input("\033[33m输入结束日期:\033[0m")
n = re.match('\d{4}-\d{2}-\d{2}',end_time)
if n > 0:
if start_time >= end_time:
print "\033[31m开始日期必须小于结束日期\033[0m"
break
else:
print "\033[32m开始查询\033[0m"
time.sleep(1)
else:
print "\033[34m格式有误!日期格式为:xxxx-xx-xx\033[0m"
break
else:
print "\033[34m格式有误!日期格式为:xxxx-xx-xx\033[0m"
break
conn = MySQLdb.connect("localhost","root","root","aaa")
cur = conn.cursor()
sql = ("select * from ccc where create_time between '%s' and '%s'" % (start_time,end_time))
result = cur.execute(sql)
print "\033[35m查询结果: %s \033[0m" % result
cur.close()
conn.commit()
conn.close()
break