Exemplo n.º 1
0
 def GetBookByName(self, keyword):
     mysql = Mysql()
     book_list = mysql.getAll("select * from book where bookname like '%" + keyword + "%'")
     mysql.dispose()
     if book_list == False:
         print('no record')
         return 0
     show = MiddleLayer()
     tums = show.ShowBook(book_list)
     return tums
Exemplo n.º 2
0
 def GetBookByDis(self, desci):
     mysql = Mysql()
     Dis_List = mysql.getAll("select * from book where discipline = '" + desci + "'")
     # print("Classification of " + desci + ":\n")
     # print("bookid\tbookname\tauthor\tpages\tcollecttime\tversion\tmajor\tdiscipline\tisbn\tbooklanguage\tpublisher\tstatus\tabstract\tstack\tshelf\tfloor\tbookvalue")
     # if Dis_List:
     #     for row in Dis_List:
     #         print("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" %(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11],row[12],row[13],row[14],row[15],row[16]))
     mysql.dispose()
     if Dis_List == False:
         print('no record')
         return 0
     show = MiddleLayer()
     tums = show.ShowBook(Dis_List)
     return tums
Exemplo n.º 3
0
 def GetAllBookRecord(self, num=0):
     mysql = Mysql()
     if (str(num) == '0'):
         sqlAll = "select * from book"
     else:
         sqlAll = "select * from book limit " + str(num)
     result = mysql.getAll(sqlAll)
     # print("bookid\tbookname\tauthor\tpages\tcollecttime\tversion\tmajor\tdiscipline\tisbn\tbooklanguage\tpublisher\tstatus\tabstract\tstack\tshelf\tfloor\tbookvalue")
     # if result :
     #     for row in result :
     # print("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" %(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11],row[12],row[13],row[14],row[15],row[16]))
     mysql.dispose()
     if result == False:
         print('no record')
         return 0
     show = MiddleLayer()
     tums = show.ShowBook(result)
     return tums
Exemplo n.º 4
0
    def GetBookByField(self, obj):
        # 拼接成Dict函数
        # 例:{'bookid': '100014', 'author': '韩强军'}
        Seq = []
        Val = []
        if obj.get_bookid() != '':
            Seq.append('bookid')
            Val.append(obj.get_bookid())
        if obj.get_bookname() != '':
            Seq.append('bookname')
            Val.append(obj.get_bookname())
        if obj.get_author() != '':
            Seq.append('author')
            Val.append(obj.get_author())
        if obj.get_pages() != '':
            Seq.append('pages')
            Val.append(obj.get_pages())
        if obj.get_collecttime() != '':
            Seq.append('collecttime')
            Val.append(obj.get_collecttime())
        if obj.get_version() != '':
            Seq.append('version')
            Val.append(obj.get_version())
        if obj.get_major() != '':
            Seq.append('major')
            Val.append(obj.get_major())
        if obj.get_discipline() != '':
            Seq.append('discipline')
            Val.append(obj.get_discipline())
        if obj.get_isbn() != '':
            Seq.append('isbn')
            Val.append(obj.get_isbn())
        if obj.get_booklanguage() != '':
            Seq.append('booklanguage')
            Val.append(obj.get_booklanguage())
        if obj.get_publisher() != '':
            Seq.append('publisher')
            Val.append(obj.get_publisher())
        if obj.get_status() != '':
            Seq.append('status')
            Val.append(obj.get_status())
        if obj.get_abstract() != '':
            Seq.append('abstract')
            Val.append(obj.get_abstract())
        if obj.get_stack() != '':
            Seq.append('stack')
            Val.append(obj.get_stack())
        if obj.get_shelf() != '':
            Seq.append('shelf')
            Val.append(obj.get_shelf())
        if obj.get_floor() != '':
            Seq.append('floor')
            Val.append(obj.get_floor())
        if obj.get_bookvalue() != '':
            Seq.append('bookvalue')
            Val.append(obj.get_bookvalue())

        Dict = dict(zip(Seq, Val))

        mysql = Mysql()
        sql = "select * from book where "
        keys = tuple(Dict.keys())
        vals = tuple(Dict.values())
        Len = len(Dict)
        for i in range(Len):
            if (i != Len - 1):
                sql = sql + keys[i] + "='" + str(vals[i]) + "' and "
            else:
                sql = sql + keys[i] + "='" + str(vals[i]) + "'"
        Book = mysql.getAll(sql)
        if Book == False:
            print('no record')
            return 0
        # if len(Book) == 0:
        #     print("No books found!")
        # else:
        #     print("The book you found:")
        #     if Book:
        #         for row in Book:
        #
        #             print("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" %\
        #                   (row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],\
        #                  row[9],row[10],row[11],row[12],row[13],row[14],row[15],row[16]))
        mysql.dispose()
        show = MiddleLayer()
        tums = show.ShowBook(Book)
        return tums