Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Show me the steps to solve in python This Milestone uses incremental programming. The autograder's unit tests will test each method individually ( with the

Show me the steps to solve in python
This Milestone uses incremental programming. The autograder's unit tests will test each method individually (with the exception of Step 1's database setup methods, which will all be tested together), independent of every other method. It is recommended to submit the program after each major step (or even during a major step) so as to ensure the implemented methods each function properly.
The following is the description of the dataset for the database, along with a full specification list and steps of what should be implemented in this Milestone program.
Dataset Description
A database of two tables will be initialized with two sets of data. The datasets for the database are provided in tab-separated value (.tsv) files: menu.tsv and user.tsv. The first row of the .tsv files contains the header, which contain the column names, while subsequent rows contain the values of each column. The description of the dataset for each table is as follows:
menu table (menu.tsv)
category - type TEXT, category of food item
item_name - type TEXT, name of food item
description - type TEXT, description of food item
price - type DECIMAL(5,2), price of food item
prep_time - type INTEGER, time required to prepare the food item (in minutes)
available - type INTEGER, availability of food item in daily menu (1= available, 0= unavailable)
user table (user.tsv)
user_name - type TEXT, username of user
account_type - type TEXT, type of user account (admin or customer)
first_name - type TEXT, first name of user
last_name - type TEXT, last name of user
email - type TEXT, email address of user
phone_number - type TEXT, phone number of user
password - type TEXT, password of user
employee_id - type TEXT, employee ID of admin user
credit_card_number - type TEXT, credit card number of customer user
credit_card_exp_date - type TEXT, expiration date of credit card of customer user
billing_address - type TEXT, credit card billing address of customer user
reward_points - type INTEGER, reward points earned by customer user
order_history - type INTEGER, receipt number of last order by customer user
Step 1: Implement database setup methods in DbManager.py
DbManager.py contains class DbManager which allows the food vendor to create and access the database. Implement the following attributes and methods for class DbManager:
Attributes
Connection conn - Connection object that, once connected, will be used throughout the program.
Instance methods
Database Setup Methods
connect()
Establishes a connection to an in-memory database.
disconnect()
Disconnects from the existing database.
create_menu_table(data_file)
Reads a .tsv file and creates a table named menu.
Calls insert_menu() to insert individual entries to the table.
insert_menu(menu)
Reads a menu tuple containing the column values of a menu entry (category, item_name, description, price, prep_time, availability).
Inserts an entry into the menu table with column values listed in the parameter.
create_user_table(data_file)
Reads a .tsv file and creates a table named user.
Calls insert_user() to insert individual entries into the table.
Step 2: Implement basic FoodVendor.py
FoodVendor.py contains class FoodVendor which controls the overall ordering system. FoodVendor.py will also be where a main method can be implemented to test the functionality of the program. FoodVendor.py has the following specifications:
Attributes
DbManager db - DbManager object that allows access to a database.
Instance methods
initialize()
Instantiates a new DbManager object.
Connects to the database.
Creates menu and user tables in the database.
Step 3: Implement user-related methods in DbManager.py
In DbManager.py, implement the following methods relating to the user table:
User-related Methods
insert_user(user)
Reads a user a tuple containing the column values of a user entry (user_name, account, first_name, last_name, email, phone_num, password, emId, card_num, card_date, address, points, history).
Inserts an entry into the user table with the column values listed in the parameter.
update_customer_rewards(name, value)
Sets a user's (whose name equals parameter name) reward points equal to parameter value.
update_customer_history(name, value)
Sets a user's (whose name equals parameter name) order history with parameter value.
is_user_exist(user_name)
Returns True if a user with name equal to parameter user_name exists in the database, otherwise returns False.
delete_user(user_name)
Removes entry of a user with name equal to parameter user_name from the database.
import csv
import sqlite3
import os
from sqlite3 import Error
from os import path
class DbManager:
def __init__(self, conn):
self.conn = None
def connect(self):
self.conn = sqlite3.connect(':memory:')
def create_menu_table(self, data_file):
self.connect()
cursor = self.conn.cursor()
cursor.execute(16 def connect(self):
image text in transcribed

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

Question

What has been your desire for leadership in CVS Health?

Answered: 1 week ago

Question

Question 5) Let n = N and Y Answered: 1 week ago

Answered: 1 week ago