Advertisement
abrar1

Untitled

Dec 11th, 2020
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. def product_info(request):
  2.     if request.session.is_empty():
  3.         return redirect(customer_view.login)
  4.     else:
  5.         if request.method == "POST":
  6.             product_name = request.POST['product_name']
  7.             description = request.POST['description']
  8.             price = request.POST['price']
  9.             warranty = request.POST['warranty']
  10.             total_product = request.POST['total_product']
  11.             #$
  12.             buying_price = request.POST['buying_product']
  13.             dict = {'product_name':product_name, 'description':description, 'price':price, 'warranty':warranty, 'total_product':total_product}
  14.  
  15.             cursor = connection.cursor()
  16.             sql = "INSERT INTO HISTORY(NAME, STOCK, PRICE, DESCRIPTION, WARRANTY,BUYING_PRICE) " \
  17.                   "VALUES(%s, %s, %s, %s, %s)"
  18.             cursor.execute(sql, [product_name, total_product, price, description, warranty, buying_price])
  19.             connection.commit()
  20.             cursor.close()
  21.             return redirect(imei_entry_load)
  22.         else:
  23.             return render(request, "Product_Info.html")
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement