redis/funcs/crud_redis.py
def update(name=False, price=False, stock=False):
    """Update an item selected by id."""
    conn = connect()
    key = input('Enter your product key: ')
    if name:
        new_name = input('Enter new product name: ')
        result = conn.hset(key, "name", new_name)
        if result:
            print('Product name successfully updated.')
            return
    if price:
        new_price = float(input('Enter new product price: '))
        result = conn.hset(key, "price", new_price)
        if result:
            print('Product price successfully updated.')
            return
    if stock:
        new_stock = int(input('Enter new product stock: '))
        result = conn.hset(key, "stock", new_stock)
        if result:
            print('Product stock successfully updated.')
            return
    else:
        print('No items have been updated.')
Update an item selected by id.
Update an item selected by id.
Update an item selected by id .
def update(name=False, price=False, stock=False):
    conn = connect()
    key = input('Enter your product key: ')
    if name:
        new_name = input('Enter new product name: ')
        result = conn.hset(key, "name", new_name)
        if result:
            print('Product name successfully updated.')
            return
    if price:
        new_price = float(input('Enter new product price: '))
        result = conn.hset(key, "price", new_price)
        if result:
            print('Product price successfully updated.')
            return
    if stock:
        new_stock = int(input('Enter new product stock: '))
        result = conn.hset(key, "stock", new_stock)
        if result:
            print('Product stock successfully updated.')
            return
    else:
        print('No items have been updated.')
def update ( name = False , price = False , stock = False ) : conn = connect ( ) key = input ( 'Enter your product key: ' ) if name : new_name = input ( 'Enter new product name: ' ) result = conn . hset ( key , "name" , new_name ) if result : print ( 'Product name successfully updated.' ) return if price : new_price = float ( input ( 'Enter new product price: ' ) ) result = conn . hset ( key , "price" , new_price ) if result : print ( 'Product price successfully updated.' ) return if stock : new_stock = int ( input ( 'Enter new product stock: ' ) ) result = conn . hset ( key , "stock" , new_stock ) if result : print ( 'Product stock successfully updated.' ) return else : print ( 'No items have been updated.' )
Update an item selected by id.
Update an item selected by id .
"""Update an item selected by id."""
name
price
stock