Esempio n. 1
0
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()
Esempio n. 2
0
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()
Esempio n. 3
0
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
Esempio n. 4
0
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
Esempio n. 5
0
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
Esempio n. 6
0
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()
Esempio n. 7
0
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()
Esempio n. 8
0
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()
Esempio n. 9
0
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()
Esempio n. 10
0
def getAllProducts():
    cur = DBConnection.connection().cursor()
    cur.execute("SELECT * FROM products")
    data = cur.fetchall()
    cur.close()
    return data
Esempio n. 11
0
def deleteProductUsingId(productId):
    db_connection = DBConnection.connection()
    cur = db_connection.cursor()
    cur.execute("DELETE from products where ProductID=" + productId)
    db_connection.commit()
    cur.close()