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 calledYOURNAME-Assignment9.
Part 1: Create the Database
Make a new file calleddatabase_generator.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:
0,Apple,$0.75,120,Fresh
1,Banana,$0.40,200,Ripe
2,Orange,$0.60,150,Juicy
3,Carrot,$0.30,300,Crisp
4,Grapes,$1.20,80,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 2: 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 database_generator.py file that you wrote above.
UI for Database Operations
Print out a menu to do the following:
1. Print all data
2. Insert data
3. Find Data
4. 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 re-prompt 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: ##? Y/N"
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!