Class 12 Cbse Cs Assignmennt
Class 12 Cbse Cs Assignmennt
S.N
TITLE PAGE.NO
0
1 Introduction
2 Explanation
3 Required Specification
4 Advantages
6 Output Screen
7 Conclution
8 Bibiliography
Page 2
When the program is run, it first creates a connection to the MySQL server
running on the local machine, using the root user and the password “admin”. It
then creates a database called “store” (if it doesn’t already exist) and uses it. It
creates a table called “signup” with columns for “username” and “password”.
This table is used to store user account information.
The program then enters a loop that presents the user with a choice between
signing up and logging in. If the user chooses to sign up, they are prompted to
enter a username and password, which are then stored in the “signup” table. If
the user chooses to log in, they are prompted to enter a username. If the
username is found in the “signup” table, the program prompts the user to enter
their password. If the password is correct, the user is presented with a menu of
options for managing the bookstore.
1. Add Books: The user is prompted to enter information about a new book
(name, genre, quantity, author, publication, and price). If the book is
already in the store, the quantity is increased. Otherwise, the book is
added to the “Available_Books” table.
2. Delete Books: The user is shown a list of available books and prompted
to enter information about a book to delete (name, quantity, customer
name, phone number, and price). If the requested quantity of the book is
available, a record of the sale is added to the “Sell_rec” table and the
quantity of the book is decreased. Otherwise, an error message is
displayed.
Page 4
Required Specification
Hardware requirement.
2. Ram: 2 GB or more
Software requirement.
import mysql.connector
mydb=mysql.connector.connect (host="localhost", user="root",
password="ritheesh@#2006")
while True:
print("""1:Signup
2:Login""")
ch=int(input("SIGNUP/LOGIN(1,2):"))
#SIGNUP
if ch==1:
username=input("USERNAME:")
pw=input("PASSWORD:")
#LOGIN
elif ch==2:
username=input("USERNAME:")
pw=input("PASSWORD:")
if a is not None:
print("""+++++++++++++++++++++++
+++LOGIN SUCCESSFULL+++
+++++++++++++++++++++++""")
print("""=====================================================
=================
++++++++++++++++++++++++++ MY BOOK STORE +++++++++++++++
++++++++++
============================================================
==============""")
while(True):
print("""1:Add Books
2:Delete Books
3:Search Books
4:Staff Details
5:Sell Record
6:Available Books
7:Total Income after the Latest Reset
8:Exit""")
#ADD BOOKS
if a==1:
Page 8
print("""++++++++++++++++++++++
++SUCCESSFULLY ADDED++
++++++++++++++++++++++""")
else:
mycursor.execute("insert into
Available_Books(bookname,genre,quantity,author,publication,price)
values('"+book+"','"+genre+"','"+str(quantity)
+"','"+author+"','"+publication+"','"+str(price)+"')")
mydb.commit()
print("""++++++++++++++++++++++
++SUCCESSFULLY ADDED++
++++++++++++++++++++++""")
#DELETE BOOKS
elif a==2:
print("AVAILABLE BOOKS...")
if max(lk)<n:
print(n,"Books are not available!!!!")
else:
mycursor.execute("select bookname from available_books
where bookname='"+book+"'")
log=mycursor.fetchone()
print("""++++++++++++++++++++++
++BOOK HAS BEEN SOLD++
++++++++++++++++++++++""")
else:
print("BOOK IS NOT AVAILABLE!!!!!!!")
print("""1:Search by name
2:Search by genre
3:Search by author""")
l=int(input("Search by?:"))
#BY BOOKNAME
if l==1:
o=input("Enter Book to search:")
tree=mycursor.fetchone()
if tree!=None:
print("""++++++++++++++++++++
++BOOK IS IN STOCK++
++++++++++++++++++++""")
else:
print("BOOK IS NOT IN STOCK!!!!!!!")
#BY GENRE
elif l==2:
g=input("Enter genre to search:")
for y in mycursor:
print(y)
else:
print("BOOKS OF SUCH GENRE ARE NOT
AVAILABLE!!!!!!!!!")
for z in mycursor:
print(z)
else:
print("BOOKS OF THIS AUTHOR ARE NOT
AVAILABLE!!!!!!!")
mydb.commit()
#STAFF DETAILS
elif a==4:
print("1:New staff entry")
print("2:Remove staff")
print("3:Existing staff details")
mycursor.execute("insert into
Staff_details(name,gender,age,phonenumber,address)
values('"+fname+"','"+gender+"','"+str(age)+"','"+str(phno)+"','"+add+"')")
print("""+++++++++++++++++++++++++++++
+STAFF IS SUCCESSFULLY ADDED+
+++++++++++++++++++++++++++++""")
mydb.commit()
#REMOVE STAFF
elif ch==2:
nm=str(input("Enter staff name to remove:"))
mycursor.execute("select name from staff_details where
name='"+nm+"'")
toy=mycursor.fetchone()
print("""+++++++++++++++++++++++++++++++++
++STAFF IS SUCCESSFULLY REMOVED++
+++++++++++++++++++++++++++++++++""")
mydb.commit()
else:
print("STAFF DOESNOT EXIST!!!!!!")
else:
print("NO STAFF EXISTS!!!!!!!")
mydb.commit()
#SELL HISTORY
elif a==5:
print("1:Sell history details")
print("2:Reset Sell history")
if ty==1:
mycursor.execute("select * from sell_rec")
for u in mycursor:
print(u)
if ty==2:
bb=input("Are you sure(Y/N):")
if bb=="Y":
mycursor.execute("delete from sell_rec")
mydb.commit()
elif bb=="N":
pass
#AVAILABLE BOOKS
Page 13
elif a==6:
mycursor.execute("select * from available_books order by
bookname")
for v in mycursor:
print(v)
else:
print("""++++++++++++++++++++
++INVALID USERNAME++
++++++++++++++++++++""")
else:
break
Page 14
1:Signup
2:Login
SIGNUP/LOGIN(1,2):1
USERNAME:"jitendra"
PASSWORD:"12345"
1:Signup
2:Login
SIGNUP/LOGIN(1,2):2
USERNAME:"jitendra"
VALID USERNAME!!!!!!
PASSWORD:"12345"
+++++++++++++++++++++++
+++LOGIN SUCCESSFULL+++
Page 15
+++++++++++++++++++++++
====================================================================
==
====================================================================
======
1:Add Books
2:Delete Books
3:Search Books
4:Staff Details
5:Sell Record
6:Available Books
8:Exit
Genre:"Programming"
Enter quantity:10
++++++++++++++++++++++
++SUCCESSFULLY ADDED++
++++++++++++++++++++++
1:Add Books
2:Delete Books
3:Search Books
4:Staff Details
5:Sell Record
6:Available Books
8:Exit
Bibiliography