Question: Create a new project in PyCharm called YOURNAME - Assignment 9 . Part 1 : Create the Database Make a new file called database _
Create a new project in PyCharm calledYOURNAMEAssignment
Part : Create the Database
Make a new file calleddatabasegenerator.py With this file you will write some SQL code to create a new database, add in a table called Products and have the following columns:
id
name
price
quantity
quality
Once the table is created insert the following data into it:
Apple,$Fresh
Banana,$Ripe
Orange,$Juicy
Carrot,$Crisp
Grapes,$Sweet
Include a SQL query to select the whole table and print the results out. This will be your check that your data got inserted correctly.
NOTE: You are not required to have main function in this file.
Part : Create main.py
Create a new file for your main.py
Connect to Database
The first thing you should do is connect to the database from your databasegenerator.py file that you wrote above.
UI for Database Operations
Print out a menu to do the following:
Print all data
Insert data
Find Data
Delete Data
Q to quit
Print all data
Print all the data in the database OR a message saying that there is no data found if empty.
Insert data
Prompt the user with inputs for all the data needed to insert into the database.
We don't want duplicate data so before adding in you should check the ID as there are no duplicate IDs. If there isn't a unique ID then reprompt for a new one. You can choose how to handle that.
Update the count that should be displayed example output below for how many rows of data there are.
Find data
Ask the user for an ID to search in the database. If there is a matching ID in the database then print the data, otherwise print a no data found message
Delete data
Prompt the user for an ID to delete. If the ID is in the database then ask the user one more time "Are you sure you want to delete data with id: ## YN
If no ID found in the database then print a message of id not existing and go back to the main prompt
You could probably use the find functionality above to help you in this.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
