0% found this document useful (0 votes)
5 views3 pages

COMPUTER Project 12th (1) Part 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

COMPUTER Project 12th (1) Part 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

print("4.

BACK")
print()
ch = int(input("Select Your Option (1-4): "))
if ch == 1:
new_name = input("Enter new name: ")
sql = "UPDATE book SET name = %s WHERE name = %s"
values = (new_name, name)
cursor.execute(sql, values)
db.commit()
print(cursor.rowcount, "record updated successfully")
elif ch == 2:
new_address = input("Enter new address: ")
sql = "UPDATE book SET address = %s WHERE name = %s"
values = (new_address, name)
cursor.execute(sql, values)
db.commit()
print(cursor.rowcount, "record updated successfully")
elif ch == 3:
new_mobile = input("Enter new mobile : ")
sql = "UPDATE book SET mobile = %s WHERE name = %s"
values = (new_mobile, name)
cursor.execute(sql, values)
db.commit()
print(cursor.rowcount, "record updated successfully")
elif ch == 4:
break
else:
print("Invalid choice !!!\n")

def main():
intro()
while True:
print("\nMAIN MENU ")
print("1. ADD NEW RECORD")
print("2. SEARCH RECORD")
print("3. DISPLAY ALL RECORDS")
print("4. DELETE RECORD")
print("5. MODIFY RECORD")
print("6. EXIT")
print()
ch = int(input("Select Your Option (1-6): "))
print()
if ch == 1:
print("ADD NEW RECORD")
create_record()

Page 5 of 11
elif ch == 2:
print("SEARCH RECORD BY NAME")
name = input("Enter name: ")
search(name)
elif ch == 3:
print("DISPLAY ALL RECORDS")
display_all()
elif ch == 4:
print("DELETE RECORD")
name = input("Enter name: ")
delete_record(name)
elif ch == 5:
print("MODIFY RECORD")
name = input("Enter name: ")
modify_record(name)
elif ch == 6:
print("Thanks for using Contact Book")
db.close()
break
else:
print("Invalid choice")

main()

Page 6 of 11
Output

Page 7 of 11

You might also like