Answered step by step
Verified Expert Solution
Question
1 Approved Answer
more students will apply their (Python) programming skills to develop a few short programs that DBVac thinks will help the company so in some
more students will apply their (Python) programming skills to develop a few short programs that DBVac thinks will help the company so in some cases than in others. Specific programming skills will include data input and output, variables, Python lists and indexes, loops, and if-statements. Background DustBunny Vacuums, a company we've heard from before, needs you to code a suite of small applications for them to help with some of the common activities performed by their employees. Two of these applications will require you to connect to (your personal version of) the DBVac database. Remembering the structure of that database might be helpful for those two, so here's an ERD: Customer PK CustID FK CustState FName LName Gender HHI Marital Children HasPets USState PK StatelD FK RegionID StateName Population Region PK RegionID RegionName HQCity PK FK SalesOrder SOID CustID SODate Order Total Service PK SvcID FK CustID FK Product SvcDate SvcDays SvcRating PK FK FK OrderLine OLID SOID ModellD ModelPrice Qty Line Total Product PK ModelID ModelName MSRP Cost ProdType Part B Customer Lookup (25 points) Write a program called lookup.py that enables DBVac employees to look up a customer by name or CustID, then output the data regarding the matching customer(s). Your program should: Include a comment in the first line with your name. Include comments describing each major section of code. Connect to your personal version of the DBVac database. Ask the user if they would like to look up the customer by ID or by name. Validate that the user enters a valid selection. O If they want to look the customer up by ID, then: O Ask the user to input a customer ID number. O Validate that what is entered is an integer. If it's not, then ask the O user to try again. Run a SQL query to get the information about the customer whose ID matches what was entered. For the matching customer, output the customer's ID, first name, last name, gender, the name of the state that the customer is from, and the population of that state (show as an integer). Print the returned record all on one line. I Provide labels for each (e.g., Last Name: Springfield, First Name: Jebediah, etc.). If they want to look the customer up by name, then: O Ask the user to input a first name (or leave blank). O O O Ask the user to input a last name. Validate that they have entered an actual value here. If they leave this null, keep asking the user for a last name until they enter something valid. Run a SQL query to get the information about the customer(s) whose name(s) match(es). If the user left the first name blank, then the query should return all customers whose last names match the last name entered. For the matching customer, output the customer's ID, first name, last name, gender, the name of the state that the customer is from, and the population of that state (show as an integer). Print the returned record all on one line. Provide labels for each (e.g., Last Name: Springfield, First Name: Jebediah, etc.). 1 Extra Credit Point: If no records are returned for a given query (of either type), tell the user that no records match the value(s) entered by the user. Ask the user if they want to look up another customer and, if so, go through this same process again. I Once the user's done entering records, say thank you and tell them, forcefully, to have a nice day.
Step by Step Solution
★★★★★
3.52 Rating (165 Votes )
There are 3 Steps involved in it
Step: 1
Solution import mysqlconnector def searchbyidcursor Ask user to input a customer ID number while Tru...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started