# generate random password
    pos = random.randint(0, length)
    newPass += abc[pos:pos + 1]
    newPass += str(random.randint(0, 99))
    pos = random.randint(0, length)
    newPass += abc[pos:pos + 1]
    pos = random.randint(0, length)
    newPass += abc[pos:pos + 1]
    pos = random.randint(0, length)
    newPass += abc[pos:pos + 1]
    pos = random.randint(0, length)
    newPass += abc[pos:pos + 1]
    newPass += str(random.randint(0, 99))
    pos = random.randint(0, length)
    newPass += abc[pos:pos + 1]
    pos = random.randint(0, length)
    newPass += abc[pos:pos + 1]

    # generate hash
    hashPass = auth.genHash(newPass)

    # update database
    cust = service.editOneByKey(doc.getKey(), {'password': hashPass})

    # write customer name, email, plain text and hashed passwords to CSV file
    f.write('"' + cust.getFullName() + '","' + cust.get('email') + '","' +
            newPass + "\"\n")

f.close()
    print("\nCustomer " + key + " added successfully")

# running a query for a single item
print("\nFetch Customer by Key")
doc = service.fetchByKey(key)
if doc:
    print(doc.toJson())

# updating a single customer
newPhone = '+9-999-999-9999'
updateDoc = {
    'phoneNumber': newPhone,
    'email': '*****@*****.**'
}

result = service.editOneByKey(key, updateDoc)
if not result:
    print("\nUnable to find this product key: " + key)
else:
    print("\nProduct " + key + " updated successfully")
    print(result.toJson())

# bad key should not perform updates
badkey = 'badkey'
result = service.editOneByKey(badkey, updateDoc)
if not result:
    print("\nUnable to find this product key: " + badkey + "\n")
else:
    print("\nProduct " + badkey + " updated successfully\n")
    print(result.toJson())