zoukankan      html  css  js  c++  java
  • 一个简单的查询脚本

    #/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-xx33[0m"
                 break
    else:
         print "33[34m格式有误!日期格式为:xxxx-xx-xx33[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

  • 相关阅读:
    HTML <iframe> 标签
    HTML <tr> 标签
    HTML <img> 标签的 border 属性
    jQuery ajax ajax() 方法
    CSS padding 属性
    SQL Server CONVERT() 函数
    CSS overflow 属性
    HTML <input> 标签
    Java动态代理一——动态类Proxy的使用
    Java拆箱装箱小结
  • 原文地址:https://www.cnblogs.com/glxsc/p/5439917.html
Copyright © 2011-2022 走看看