Menu.
py
def MenuBook():
while True:
[Link]()
print("\t\t\t SlamBook\n")
print("=====================================================")
print("1. Add Record ")
print("2. Display Records ")
print("3. Search Record ")
print("4. Delete Record ")
print("5. Update Record ")
print("6. Return to Main Menu ")
print("=====================================================")
choice=int(input("Enter Choice between 1 to 5-------> : "))
if choice==1:
[Link]()
elif choice==2:
[Link]()
elif choice==3:
[Link]()
elif choice==4:
[Link]()
elif choice==5:
print("No such Function")
elif choice==6:
return
else:
print("Wrong Choice......Enter Your Choice again")
x=input("Enter any key to continue")
#----------------------------------------------------------------------------------------
Slam_Book .py
import Menu
import SBook
while True:
[Link]()
print("\t\t\t Slam Book Management\n")
print("=====================================================")
[Link]()
print("====================================================")
[Link]
import [Link]
from [Link] import errorcode
from datetime import date, datetime, timedelta
from [Link] import (connection)
import os
import platform
def clrscreen():
if [Link]()=="Windows":
print([Link]("cls"))
def display():
try:
[Link]('cls')
cnx = [Link](user='root', password='mysql', host='localhost',
database='slambook')
Cursor = [Link]()
query = ("SELECT * FROM friends")
[Link](query)
for (id,name,addess,phno) in Cursor:
print("--------------------------------------------------------------------")
print("id : ",id)
print("Name : ",name)
print("address : ",address)
print("phno : ",phno)
print("------------------------------------------------------------")
[Link]()
[Link]()
print("completed !!!!!!")
except [Link] as err:
if [Link] == errorcode.ER_ACCESS_DENIED_ERROR: print("Something is wrong
with your user name or password") elif [Link] ==
errorcode.ER_BAD_DB_ERROR: print("Database does not exist")
else:
print(err)
else:
[Link]()
def insertData():
try:
cnx = [Link](user='root',
password='mysql',
host='[Link]',
database=‘slambook’)
Cursor = [Link]()
id=input("Enter id : ")
name=input("Enter Name : ")
add=input("Enter address : ")
ph=int(input("Enter phno : "))
"VALUES (%s, %s, %s, %s, %s, %s, %s)")
data = (id,name,add,ph)
[Link](Qry,data)
Make sure data is committed to the database [Link]()
[Link]()
[Link]()
print("data saved successfully............")
except [Link] as err:
if [Link] == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif [Link] == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
[Link]()
def deletedata():
try:
cnx = [Link](user='root',
password='mysql',
host='[Link]',
database=‘slambook’)
Cursor = [Link]()
id=input("Enter id of friend to be deleted : ")
Qry =("""DELETE FROM Friends WHERE id = %s""")
del_rec=(id,)
[Link](Qry,del_rec)
Make sure data is committed to the database [Link]()
[Link]()
[Link]()
print([Link],"Record(s) Deleted Successfully.............")
except [Link] as err:
if [Link] == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif [Link] == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
[Link]()
def Searchfrnd():
try:
cnx = [Link](user='root',
password='mysql',
host='[Link]',
database=‘slambook’)
Cursor = [Link]()
id=input("Enter id be Searched from the friends : ")
query = ("SELECT * FROM Friends where id = %s ")
rec_srch=(id,)
[Link](query,rec_srch)
Rec_count=0
for (Bno,Bname,Author,price,publ,qty,d_o_purchase) in Cursor:
Rec_count+=1
for (id,name,addess,phno) in Cursor:
print("--------------------------------------------------------------------")
print("id : ",id)
print("Name : ",name)
print("address : ",address)
print("phno : ",phno)
print("------------------------------------------------------------")
if Rec_count%2==0:
input("Press any key to continue")
clrscreen()
print(Rec_count, "Record(s) found")
Make sure data is committed to the database [Link]()
[Link]()
[Link]()
except [Link] as err:
if [Link] == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif [Link] == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
[Link]()
def Updatefrnd():
try:
cnx = [Link](user='root',
password='mysql',
host='[Link]',
database=‘slambook’)
Cursor = [Link]()
id=input("Enter id of frined to be Updated : ")
query = ("SELECT * FROM Friends where id = %s ")
rec_srch=(id,)
print("Enter new data ")
name=input("Enter new Name : ")
add=input("Enter address : ")
ph=input("Enter phno: ")
Qry = ("UPDATE Friends SET name=%s,address=%s,"\ "phno=%s "\
"WHERE id=%s")
data = (name,add,ph, bno)
[Link](Qry,data)
Make sure data is committed to the database''' [Link]()
[Link]()
[Link]()
print([Link],"Record(s) Updated Successfully.............")
except [Link] as err:
if [Link] == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif [Link] == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
[Link]()
Updatefrnd()