Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python, 9 . 2 Wk 4 Milestone 2 ( Part 2 - Database access with users ) In this lab, the DbManager class created

Using Python, 9.2 Wk 4 Milestone 2(Part2- Database access with users)
In this lab, the DbManager class created in Milestone 1 is extended to include new functionalities associated with the new user classes. You can use your Users.py, from Part1 of Milestone 2, DbManager.py and FoodVendor.py from Milestone 1 to complete this lab. Alternatively, copy and paste all the attributes and instance methods created in your recent submissions to the new template files provided here.
To include the new functionalities, DbManager.py has the following extra specifications:
Instance methods
update_admin(user)
Update the database with the phone number and email address of parameter user.
get_admin(user_name)
Return an Admin user that is in the database with username equals to the parameter. If the user is not found, return an Admin user with all attributes ="".
update_customer(user)
Update the database with the credit card number, expiration date, billing address, phone number, and email address of parameter user.
get_customer(user_name)
Return a customer that is in the database with username equals to the parameter. If the user is not found, return a customer with all attributes to "" or 0.
There is no new specification for FoodVendor.py; however, modify the main method in the FoodVendor.py you have submitted for Milestone 1 to test the program. See examples in the template file. import sqlite3, os
from sqlite3 import Error
from os import path
from DbManager import DbManager
from Users import User, Admin, Customer
class FoodVendor:
# TODO: copy and paste instance method initialize() created from Part 1 of Milestone 1 here.
if __name__=='__main__':
vendor = FoodVendor()
vendor.initialize()
# Test cases
# Test get_customer()
print('Test get_customer() with username from database')
customer_user = vendor.db.get_customer("gwarner653");
print('customer_user: {}'.format(customer_user))
# Test get_admin()
print('Test get_admin() with username from database')
admin_user = vendor.db.get_admin("rebradshaw835");
print('admin_user: {}'.format(admin_user))
# TODO: test other member methods of DbManager
vendor.db.disconnect()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions