#/usr/bin/env python
#coding:utf-8
import re
import MySQLdb
import time
while True:
start_time = raw_input(" 33[33m输入开始日期: 33[0m")
m = re.match('d{4}-d{2}-d{2}',start_time)
if m > 0:
end_time = raw_input(" 33[33m输入结束日期: 33[0m")
n = re.match('d{4}-d{2}-d{2}',end_time)
if n > 0:
if start_time >= end_time:
print " 33[31m开始日期必须小于结束日期 33[0m"
break
else:
print " 33[32m开始查询 33[0m"
time.sleep(1)
else:
print " 33[34m格式有误!日期格式为:xxxx-xx-xx 33[0m"
break
else:
print " 33[34m格式有误!日期格式为:xxxx-xx-xx 33[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 " 33[35m查询结果: %s 33[0m" % result
cur.close()
conn.commit()
conn.close()
break