def get_product_detail(id): if (id<1): return try: cursor=productConn.cursor() sql=("select Value as price from Productdb.productdetail where ProductID=%(pid)s") data={"pid":id} cursor.execute(sql,data) result=cursor.fetchall() cursor.close() return result except: print (exc_info()) cursor.close()
def get_product_brand(id): if (id<1): return try: cursor=productConn.cursor() sql=("select brandname from productdb.brands where brand_id=%(bid)s") data ={"bid":id} cursor.execute(sql,data) result=cursor.fetchall() cursor.close() return result except: print (exc_info()) cursor.close()
def get_product_link(id): if (id<1): return try: cursor=productConn.cursor() sql=("select Url from Productdb.links where ProductID=%(pid)s") data={"pid":id} cursor.execute(sql,data) result=cursor.fetchall() cursor.close() return result; except: print (exc_info()) cursor.close()
def searchProduct(keyword): try: cursor=productConn.cursor() sql=("select ID, Brand_id, ProductType_id, Name from productdb.Products where Brand_ID in (select Brand_ID from productdb.Brands where BrandName like CONCAT('%', %(key)s, '%'))" "or ProductType_ID in (select ProductType_ID from productdb.productTypes where TypeName like concat('%',%(key)s,'%')" "or Name like concat('%',%(key)s,'%'))") data={"key":keyword} cursor.execute(sql,data) result=cursor.fetchall() cursor.close() if (result is not None): return result except: print(exc_info()) cursor.close()