Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python - Lab - Database CRUD - Instructions Write a program to perform database CRUD operations. We are writing all of the code together in

image text in transcribed
Python - Lab - Database CRUD - Instructions Write a program to perform database CRUD operations. We are writing all of the code together in class. We can have a menu something like this: Welcome to my database program! Menu : Enter S to get started and create a new database Enter C to create a new row Enter R to retrieve data Enter U to update a row Enter D to delete a row Enter Q to quit the program Enter your choice: Suggested functions below. Feel free to change the code as you like, just be sure to: 1.) offer the same menu options as above 2.) do the CRUD operations 3.) use functions with parameter passing. Function Name Parameters Return Processing General main None Call connect_to_db. Call display_menu. connect_to_db db Connect to the database. conn, Get database cursor. db cursor display_menu db conn, None Loop: Display menu. Ask for user input. If invalid db cursor menu choice, print error message and "try again". If valid, call appropriate function. Commit to the database. Call select_all to display rows. Ask user if want to loop again. Quit loop if user chooses DDL (Data Definition Language) create_table db cursor None Execute SQL: create drop_table db cursor None Execute SQL: drop DML (Data Manipulation Language) (CRUD) insert row db cursor None Ask user for field values. Execute SQL: insert select all db cursor None Execute SQL select without where. Print results. select_row db cursor None Ask user for key. Execute SQL select with where. Print results. update_row db cursor None Ask user for key. Ask user for new field values. Execute SQL: update. delete_row db cursor None Ask user for key. Execute SQL: delete. Note: When executing SQL, we will: 1) Create a variable that contains the SQL statement string. 2) Execute the SQL statement 3) Print a message stating that action was successful

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions