final project
final project
import mysql.connector
db=mysql.connector.connect(host="local
host",
user="root",
password="ashish",
database="book_store"
C = db.cursor()
#ADMINFUNCTION
def ADD():
genre=str(input("Genre:"))
quantity=int(input("Enter quantity:"))
publication=str(input("Enterpublicationhou
DB.commit() print("""+++++++++++++++++++++++
+SUCCESSFULLY
ADDED++++++++++++++++++++++++""")
n=int(input("""WantToContinu
e: Yes: 1
NO: 2
OPTION:""")
if n==1:
ADD()
if n==2:
Staff()
def NewStaff():
fname=str(input("EnterFullname
:"))
gender=str(input("Gender(M/F/O):"))
age=int(input("Age:"))
add=str(input("Address:"))
db.commit()
print("""+++++++++++++++++++++++++++++
+STAFFISSUCCESSFULLYADDED+
+++++++++++++++++++++++++++++""")
n=int(input("""WantToContinu
e: Yes: 1
NO: 2
OPTION:""")
if n==1:
NewStaff(
)if n==2:
Staff()
def RemoveStaff():
n=(input("StaffNametoRemove:"))
C.execute("DELETEFROMstaff_detailsWHEREName=('{}')".format(n
)) DB.commit()
print("AboveEmployeeispromotedtoCustomer")
n=int(input("""Want To Continue:
Yes: 1
NO: 2
OPTION:""")
if n==1:
RemoveStaff
()if n==2:
Staff()
def StaffDetailfS():
spl_statement="Select*fromstaff_detail
s"
C.execute(spl_statement)
output=C.fetchal
l() for x in
output:
print("******************************
print("*******************************
*****")
n=int(input("""WantToContinu
e: Yes: 1
NO: 2
OPTION:""")
if n==1:
StaffDetail
()if n==2:
Staff()
def SellRec():
C.execute("select*fromsell_rec
") for u in C:
print("*****************************************
print("BuyerMobileNumber:",u[1])
print("*****************************************
Yes: 1
NO: 2
OPTION:""")
if n==1:
SellRec(
)if n==2:
Staff()
def DelRec():
bb=input("Areyousure(Y/
N):").upper() if bb=="Y":
C.execute("deletefromsell_rec")
db.commit()
n=int(input("""WantToContinu
e: Yes: 1
NO: 2
OPTION:""")
if n==1:
DelRec(
)if n==2:
Staff()
def TotalIncome():
C.execute("selectsum(price)fromsell_re
c") for x in C:
n=int(input("""WantToContinue:
Yes: 1
NO: 2
OPTION:""")
if n==1:
TotalIncome
()if n==2:
Staff()
def AvailablefS():
C.execute("select*fromavailable_booksorderby bookname")
for v in C:
print("*************************************************
print("PublicationHouse:",v[
print("****************************************************")
n=int(input("""Want To Continue:
Yes: 1
NO: 2
OPTION:""")
if n==1:
AvailablefS
()if n==2:
Staff()
#***************************************BUYER
FUNCTION********************************************
def AvailablefU():
C.execute("select*fromavailable_booksorderby bookname")
for v in C:
print("*************************************************
print("PublicationHouse:",v[
print("****************************************************")
n=int(input("""Want To Continue:
Yes: 1
NO: 2
OPTION:""")
if n==1:
AvailablefU
()if n==2:
Buyer()
def StaffDetailfU():
spl_statement="Select*fromstaff_detail
s"C.execute(spl_statement)
output=C.fetchal
l() for x in
output:
print("*******************************
print("PhoneNoofEmploy",x[3])
print("*******************************
*****") n=int(input("""Want To
Continue:
Yes: 1
NO: 2
OPTION:""")
if n==1:
StaffDetailfU
()if n==2:
Buyer()
def Purchase():
print("AVAILABLEBOOKS...")
C.execute("select*fromavailable_Book
s")
for i in C:
print("*********************************************
print("PublicationHouse:",i[4]
print("****************************************************")
cusname=str(input("Entercustomername:"))
n=int(input("Enter quantity:"))
C.execute("selectquantityfromavailable_bookswherebookname='"+book+
"'") k=C.fetchone()
if max(k)<n:
print(n,"Booksarenotavailable!!!!
") else:
C.execute("selectbooknamefromavailable_bookswherebookname='"+book+"'")
log=C.fetchone()
C.execute("updateAvailable_Bookssetquantity=quantity-'"+str(n)+"'where
BookName='"+book+"'")
db.commit() print("""++++++++++++
++++++++++
++BOOKHASBEEN SOLD++
++++++++++++++++++++++""")
else:
print("BOOKISNOT AVAILABLE!!!!!!!")
n=int(input("""WantToContinue:
Yes: 1
NO: 2
OPTION:""")
if n==1:
Purchase(
) if n==2:
Buyer()
def
UsingName():
o=input("EnterBookto search:")
C.execute("selectbooknamefromavailable_bookswherebookname='"+o+
"'") t=C.fetchone()
If t != None:
print("""++++++++++++++++++++
++BOOKISINSTOCK++
++++++++++++++++++++""")
else:
print("BOOKISNOTINSTOCK!!!!!!!")
n=int(input("""WantToContin
ue: Yes: 1
NO: 2
OPTION:""")
if n==1:
UsingName(
) if n==2:
Buyer()
def UsingGenre():
g=input("Entergenreto search:")
C.execute("selectgenrefromavailable_bookswheregenre='"+g+"'")
poll=C.fetchall()
print("""++++++++++++++++++++
++BOOKISIN STOCK++
++++++++++++++++++++""")
C.execute("select*fromavailable_bookswheregenre='"+g+"'")
for y in C:
print("*****************************************
print("QuantityAvailable:",y
y[3]) print("Book
Publication: ",y[4])
print("*******************************************")
else:
print("BOOKSOFSUCHGENREARENOTAVAILABLE!!!!!!!!!")
n=int(input("""WantToContin
ue: Yes: 1
NO: 2
OPTION:""")
if
n==1:
UsingGenre()
if
n==2: Buyer()
def UsingAuthor():
o=input("EnterBook'sAuthorto search:")
C.execute("selectbooknamefromavailable_bookswhereAuthor='"+o
+"'") t=C.fetchone()
ift!= None:
print("""++++++++++++++++++++
++BOOKISINSTOCK++
++++++++++++++++++++""")
else:
print("BOOKISNOTINSTOCK!!!!!!!")
n=int(input("""WantToContin
ue: Yes: 1
NO:2
OPTION:"""))
if n==1:
UsingGenre
()if n==2:
Buyer()
def Staff():
print("""1:AddBooks
2. StaffDetails
3. SellRecord
4. TotalIncomeaftertheLatestReset
5. SeeAvailable Book
6. Exit""")
n=int(input("EnterYourChoice:"))
#ToAddBooksintothedatabas
e if n==1:
ADD()
#ChoiceForNewStaff,Firestaff,ViewSta
ff if n==2:
print("""1:Newstaffentry)
2:Remove staff
3:Existingstaffdetails""")
ch=int(input("Enteryourchoice:"))
#NEWSTAFF ENTRY
if ch==1:
NewStaff(
#REMOVE STAFF
if ch==2:
RemoveStaff(
#EXISTINGSTAFFDETAILS
if ch==3:
StaffDetail()
#ToSeeSellinghistroy&alteringi
t if n==3:
print("""1:Sellhistorydetail
s 2:Reset Sell
history""")
ty=int(input("Enteryourchoice:"))
if ty==1:
SellRec()
if ty==2:
DelRec()
#ToviewtotalTotalIncome
if n==4:
TotalIncome()
#ViewingAvailableBookAsSta
ff if n==5:
AvailablefS()
#Break
if n==6:
return
defBuyer():
#USERChoices
print("""1.PurchaseBooks
2.Search Books
3.AvailableBooks
4.StaffDetails
5. Exit""")
r=int(input("EnterYourChoice:"))
#TOPURCHASEBOOK
if r==1:
Purchase()
#SearchingofbooksusingName,Genre,Aut
hor
if r==2:
print("""1:Search by name
2:Search by genre
3:Searchbyauthor""")
l=int(input("SearchbyWhat:"))
#SearchingUsingNameofBoo
k if l==1:
UsingName()
#SearchingUsingGenreofBoo
k if l==2:
UsingGenre()
#SearchingUsingAuthorNam
if l==3:
UsingAuthor()
#ToSeeAvailableBoo
ks
if r==3:
AvailablefU()
#ToSeePresentStaffDetails
if r==4:
StaffDetail()
#MAINPROGRAM
print("**********************************************WelcomeToBook
Store***************************************************")
while 1:
a=int(input("""EnterasEmployee:1
EnterasUser:2
Exit : 3
Enter:"""))
if a==1:
Staff()
if a==2:
print('''''****************BOOKSHOP*********************
1.Signup
2.login''')
s=int(input("EnterYourChoice:"))
#Sign-Up
if s==1:
user_name=input("USERNAME(ex:abcd1234):")
password=input("PASSWORD: ")
C.execute("insertintosignupvalues('"+user_name+"','"+password+"')
") DB.commit()
print("SignUpCompleted")
#Log in
else:
user2=input("EnterYourUsername:")
C.execute("selectusernamefromSignupwhereusername='"+user2+"'
") b=C.fetchone()
b1=input("EnterYourPassword:")
C.execute("selectpasswordfromsignupwherepassword='"+b1+"'")
a2=C.fetchone()
ifa2isnotNone:
print("************************LoginSuccess********************")
Buyer(
)if
a==3:
break
DatabaseTable
1. TableSignupwithallentries.
2. Tableavailable_bookswithallentries.
3.Tablesell_recwithallentries.
4.Tablestaff_detailswithallentries.
5AlltablesunderDatabasebook_store.
Output
1. Home Screen:
2. AddBooks:
3. StaffDetails:
AddStaff details:
RemovalOfStaff:
4. SellingHistory
5. ViewingAvailableBooksasAdmin
6. ExitingAdminMenu
1. EnteringintoBuyer(User)Menu:
2. SignUp
3. Login
4. PurchasingaBook:
5. SearchingBooks:
:Using Name:
:Using Author:
:Using Genre:
39
BookStoreManagement
Reference
Computer Science with Python Class XI by
Sumita Arora
ComputerSciencewithPythonTextbookforClass11:SumitaArora:Amazon.in: Books
Computer Science with Python Class XII by
Sumita Arora
ProgressInComputerScienceWithPython...bySumitaArora(amazon.in)
PythonIDLE
DownloadPython|Python.org
MySQL
MySQL::MySQLDownloads