美文网首页
2019-06-20

2019-06-20

作者: kamanda | 来源:发表于2019-06-20 18:57 被阅读0次

    python 生成当前时间时间戳

    int(time,time()*1000)
    

    获取指定年月日时间戳

    def get_end_time(x2, y2, z2):
        s = datetime.datetime(x2, y2, z2, 00, 00, 00)
        print(s)
        end_time = int(time.mktime(s.timetuple())) * 1000
    

    python 连接数据库

    db = pymysql.connect(
            host='cn-master.cgl0jlkt5nez.rds.cn-north-1.amazonaws.com.cn',
            user='jialin',
            password='jialin',
            db='stats',
            port=3306
                            )
    #创建游标
    coursor = db.cursor()
     # 需要执行的sql
    sql = 'select * from t_record_start where rstart_appChannel="{0}" and rstart_type="1"' \
           ' and rstart_platform="2" and rstart_clientCreateDate between "{1}" and ' \
           '"{2}"'.format(i, start_time, end_time)
     # 执行游标     a 为查询到数据数量
     a = coursor.execute(sql)       
     # 打印出每一条查询结果
     for y in range(a):
         result = coursor.fetchone()
         print(result)
    # 关闭连接   
    db.close()
    

    相关文章

      网友评论

          本文标题:2019-06-20

          本文链接:https://www.haomeiwen.com/subject/ehtsqctx.html