couch/funcs/crud_couch.py
def update(name=False, price=False, stock=False):
    """Update an item selected by id."""
    db = connect()
    if db:
        key = input('Enter your product id: ')
        try:
            doc = db[key]
            if name:
                doc['name'] = input('Enter new product name: ')
                db[doc.id] = doc
                print('Product name successfully updated.')
                return
            if price:
                doc['price'] = float(input('Enter new product price: '))
                db[doc.id] = doc
                print('Product price successfully updated.')
                return
            if stock:
                doc['price'] = int(input('Enter new product stock: '))
                db[doc.id] = doc
                print('Product stock successfully updated.')
                return
            else:
                print('No items have been updated.')
        except couchdb.http.ResourceNotFound as e:
            print(f'Product not found. {e}')
    else:
        print('Connection Error.')
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()
    if db:
        key = input('Enter your product id: ')
        try:
            doc = db[key]
            if name:
                doc['name'] = input('Enter new product name: ')
                db[doc.id] = doc
                print('Product name successfully updated.')
                return
            if price:
                doc['price'] = float(input('Enter new product price: '))
                db[doc.id] = doc
                print('Product price successfully updated.')
                return
            if stock:
                doc['price'] = int(input('Enter new product stock: '))
                db[doc.id] = doc
                print('Product stock successfully updated.')
                return
            else:
                print('No items have been updated.')
        except couchdb.http.ResourceNotFound as e:
            print(f'Product not found. {e}')
    else:
        print('Connection Error.')
def update ( name = False , price = False , stock = False ) : db = connect ( ) if db : key = input ( 'Enter your product id: ' ) try : doc = db [ key ] if name : doc [ 'name' ] = input ( 'Enter new product name: ' ) db [ doc . id ] = doc print ( 'Product name successfully updated.' ) return if price : doc [ 'price' ] = float ( input ( 'Enter new product price: ' ) ) db [ doc . id ] = doc print ( 'Product price successfully updated.' ) return if stock : doc [ 'price' ] = int ( input ( 'Enter new product stock: ' ) ) db [ doc . id ] = doc print ( 'Product stock successfully updated.' ) return else : print ( 'No items have been updated.' ) except couchdb . http . ResourceNotFound as e : print ( f'Product not found. {e}' ) else : print ( 'Connection Error.' )
Update an item selected by id.
Update an item selected by id .
"""Update an item selected by id."""
name
price
stock