firebase/funcs/crud_firebase.py
def update(name=False, price=False, stock=False):
    """Update an item selected by id."""
    db = connect()

    key = input('Enter your product id: ')
    product = db.child('products').child(key).get()
    if product.val():
        if name:
            db.child('products').child(key).update({"name":input('Enter new product name: ')})
            print('Product name successfully updated.')
            return
        if price:
            db.child('products').child(key).update({"price":float(input('Enter new product price: '))})
            print('Product price successfully updated.')
            return
        if stock:
            db.child('products').child(key).update({"stock":int(input('Enter new product stock: '))})
            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):
    db = connect()
    key = input('Enter your product id: ')
    product = db.child('products').child(key).get()
    if product.val():
        if name:
            db.child('products').child(key).update({"name":input('Enter new product name: ')})
            print('Product name successfully updated.')
            return
        if price:
            db.child('products').child(key).update({"price":float(input('Enter new product price: '))})
            print('Product price successfully updated.')
            return
        if stock:
            db.child('products').child(key).update({"stock":int(input('Enter new product stock: '))})
            print('Product stock successfully updated.')
            return
        else:
            print('No items have been updated.')
def update ( name = False , price = False , stock = False ) : db = connect ( ) key = input ( 'Enter your product id: ' ) product = db . child ( 'products' ) . child ( key ) . get ( ) if product . val ( ) : if name : db . child ( 'products' ) . child ( key ) . update ( { "name" : input ( 'Enter new product name: ' ) } ) print ( 'Product name successfully updated.' ) return if price : db . child ( 'products' ) . child ( key ) . update ( { "price" : float ( input ( 'Enter new product price: ' ) ) } ) print ( 'Product price successfully updated.' ) return if stock : db . child ( 'products' ) . child ( key ) . update ( { "stock" : int ( input ( 'Enter new product stock: ' ) ) } ) 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