Question
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
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.
If they want to look the customer up by ID, then: Ask the user to input a customer ID number.
Validate that what is entered is an integer. If it’s not, then ask the 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.
Provide labels for each (e.g., Last Name: Springfield, First Name: Jebediah, etc.).
If they want to look the customer up by name, then: Ask the user to input a first name (or leave blank).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.
Once the user’s done entering records, say thank you and tell them, forcefully, to have a nice day.
Step by Step Solution
3.48 Rating (161 Votes )
There are 3 Steps involved in it
Step: 1
Answer Import the necessary database library import sqlite3 Replace with the appropriate library for your database Function to get customer informatio...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