def updatePassword(userName, newPassword): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute("UPDATE users SET Password=%s where userName=%s", (newPassword, userName)) db_connection.commit() cur.close()
def walletBalance(wallet, userName): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute("UPDATE users SET Wallet=%s where userName=%s", (wallet, userName)) db_connection.commit() cur.close()
def getUserByUserName(userName): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute("Select * from users where UserName=%s", userName) data = cur.fetchone() db_connection.commit() cur.close() return data
def getAllUser(): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute("Select * from users ") data = cur.fetchall() db_connection.commit() cur.close() return data
def getProductUsingId(productID): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute("SELECT * FROM products where ProductID=" + str(productID)) data = cur.fetchone() db_connection.commit() cur.close() return data
def updateOrders(product_list, userName): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute( "update users set OrderedProducts='{0}' where UserName='******'".format( product_list, userName)) db_connection.commit() cur.close()
def createUser(name, userName, password, email, gender, dob, phoneNumber, walletBalance): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute( "INSERT INTO users (FullName,UserName, Password,Email,Gender,DateOfBirth,PhoneNumber, Wallet) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)", (name, userName, password, email, gender, dob, phoneNumber, walletBalance)) db_connection.commit() cur.close()
def updateProduct(productId, productName, category, subCategory, description, image, price, discount): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute( "UPDATE products SET ProductName=%s,Category=%s,SubCategory=%s,Description=%s,Image=%s,Price=%s,Discount=%s where ProductID=%s", (productName, category, subCategory, description, image, price, discount, productId)) db_connection.commit() cur.close()
def addProduct(tableName, ProductName, Category, SubCategory, Description, Image, Price, Discount): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute( "INSERT INTO " + tableName + "(ProductName, Category, SubCategory,Description, Image, Price, Discount) VALUES (%s,%s,%s,%s,%s,%s,%s)", (ProductName, Category, SubCategory, Description, Image, Price, Discount)) db_connection.commit() cur.close()
def getAllProducts(): cur = DBConnection.connection().cursor() cur.execute("SELECT * FROM products") data = cur.fetchall() cur.close() return data
def deleteProductUsingId(productId): db_connection = DBConnection.connection() cur = db_connection.cursor() cur.execute("DELETE from products where ProductID=" + productId) db_connection.commit() cur.close()