• 大二下学期团队项目(分类查询)


    今日主要完成了,查询排序页面的bug修改,之前写的查询排序对于热门(根据评论人数确定)排序有问题,经过排查是因为存入数据库的人数是字符串,数据库按字符串进行的排序。还有日期问题,日期中有日期与上映的地点,这样的话也不能按时间进行排序。

    所以将数据库的scorenum的类型改为了int,对于日期中的杂乱数据进行了清除。

    def update_time_num():
        cursor = None
        conn = None
        conn, cursor = get_conn()
        i = 5904;
        while i <=5906:
            print(i)
            i_str = '%s' % i
            i = i + 1
            # sql = "select meet from paper_data where id=" + i_str
            # cursor.execute(sql)
            # res = cursor.fetchall()
            # if(res!=()):
            # title_update=replace(res[0][0])
            try:
                sql_0="select scorenum from moviebean where id ="+i_str
                cursor.execute(sql_0)
                res = cursor.fetchall()
                print(res)
                print(res[0][0][1:len(res[0][0])])
                sql = "update  moviebean set scorenum = %s where id=" + i_str
                cursor.execute(sql, [res[0][0][1:len(res[0][0])]])
            except:
                traceback.print_exc()
                print("无此id", i)
        conn.commit()
    
    
    def find_class_order(str):
        sql="select title,star,director,score,date_time,area,type_movie,scorenum,img from moviebean where 1=1 " 
            "and (type_movie like "+"'%"+str[0]+"%'"+") and (date_time like "+"'%"+str[1]+"%'"+") and(area like "+"'%"+str[2]+"%'"+") "
        if(str[3]=="star_1"):
            sql=sql+" order by score desc "
        if(str[3]=="star_0"):
            sql=sql+" order by score "
        if(str[3]=="hot_1"):
            sql=sql+" order by scorenum desc "
        if(str[3]=="hot_0"):
            sql=sql+" order by scorenum "
        if(str[3]=="time_1"):
            sql=sql+" order by date_time desc "
        if(str[3]=="time_0"):
            sql=sql+" order by date_time "
        sql=sql+"limit "+str[4]+",20 "
        print(sql)
        res = query(sql)
        print(res)
        return res
  • 相关阅读:
    POJ_3104_Drying_(二分,最小化最大值)
    POJ_3273_Monthly_Expense_(二分,最小化最大值)
    POJ_3185_The_Water_Bowls_(反转)
    POJ_2566_Bound_Found_(尺取法+前缀和)
    POJ_3061_Subsequence_(尺取法)
    POJ_3258_River_Hopscotch_[NOIP2015]_(二分,最大化最小值)
    POJ_1064_Cable_master_(二分,假定一个解并判断是否可行)
    POJ_2456_Agressive_cows_(二分,最大化最小值)
    背包九讲之三(多重背包)
    背包九讲之二(完全背包)
  • 原文地址:https://www.cnblogs.com/fengchuiguobanxia/p/14762938.html
Copyright © 2020-2023  润新知