KEMBAR78
Project | PDF | User (Computing) | Computer Architecture
0% found this document useful (0 votes)
5 views12 pages

Project

Uploaded by

jhah71201
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 views12 pages

Project

Uploaded by

jhah71201
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/ 12

TOPIC:

‘BOOKSTORE MANAGEMENT’

SUBMITTED BY:
NAME:MOHIT
CLASS:XII Marigold
ROLLNO:12114
SUBMITTED TO:
MR.FARROUKH NADEEM
(Subject Teacher: Computer Science)










Book Store Management 4

Hardware & Software Requirement

#Software Specifications:
Operating System: - Windows 10 or Up
Platform: - Python IDLE 3.12 64 bit
Database: - MySQL
Language: - Python

#Hardware Specifications:
Processor: - Intel i5 12th Generation
Hard Disk: - 512 GB
RAM: - 8 GB RAM
SOURCE CODE
import mysql.connector as mc
Db = mc.connect(host = 'localhost',user = 'root',password = '123456'
,database = 'Bookstore')

cur = Db.cursor()

# CREATING A MAINMENU OPTION


while True:
print(''' Welcome at e-Bookstore
A)SIGN Up
B)log in
''')
L = input()
if L.upper() == 'A':
SIGN()
elif L.upper() == 'B':
LOG()
else:
print('invalid option')
print(''' Select your prefences
1. Add book
2. Search a book
3. View all book details
4. Update book details
5. delete book details
6. Buy a book
7. Exit
''')
ch = int(input())
if ch == 1:
ADD()
elif ch == 2:
SEARCH()
elif ch == 3:
DISPLAY()
elif ch == 4:
UPDATE()
elif ch == 5:
DELETE()
elif ch == 6:
BUY_BOOK()
elif ch == 7:
print('bye bye')
break
else :
print('Invalid choice')

# 1. ADD A ROW
def ADD():
Bookid = input('Enter book id:')
BName = input('Enter book name:')
Genre = input('Enter its category:')
Quantity = input('Enter quantity:')
Price = float(input('Enter price:'))
sq = f'insert into Book_details values({Bookid},{BName},{Genre},{Quantity},
{Price});'
cur.execute(sq)
Db.commit()
# 2. SEARCH
def SEARCH():
print('''1.search by book id
2. search by bookname''')
s = int(input())
if s == 1:
Id = input("Enter bookid you want to search")
sq = f'Select * from Book_details where Bookid = {Id}'
cur.execute(sq)
Data = cur.fetchall()
print(Data)

if s==2 :
name = input('enter boook name')
sq = f'Select * from Book_details where BName ={name}'
cur.execute(sq)
Data = cur.fetchall()
print('Record found',Data)

#3. View all details


def Display():
sq = 'select * from Book_details'
cur.execute(sq)
Data = cur.fetchall()
if len(Data) >= 1:
print('Bookid BName Genre Quantity Price')
for i in Data:
print('All details',i[0],i[1],i[2],i[3],i[4])

#4. update bookdetails


def UPDATE():
ID = input('Enter book id you want to change')
print('''1. Modify Bookname
2. Modify Price''')
M = int(input())
if M == 1:
Name = input('enter new name ')
cur.execute(f'update Book_details set BName={Name} where Bookid ={ID}')
Db.commit()
elif M ==2:
Price = float(input('Enter new price'))
cur.execute(f'update Book_details set Price={Price} where Bookid ={ID}')
Db.commit()
print('Updation successfully')
#5. delete a book detail
def DELETE():
Bid = input('enter bookid you want to delete')
cur.execute(f'delete from Book_details where Bookid = {Bid}')
Db.commit()
print('deletion succesfully')

#a) sign in
def SIGN():
user = input('enter username')
pas = input('enter password')
cur.execute(f'insert into User values({user},{pas})')
Db.commit()
print('Sign up succesfully')

# B) login
def LOG():
user = input('enter username')
paswd = input('enter password')
Data = cur.execute(f'select * from User where Username = {user}')
for i in Data:
if paswd == i[1]:
print('login successful')
# 6. BUYING A BOOK
def BUY_BOOK():
Bookid = int(input("Enter Book ID to buy: "))
quantity = int(input("Enter quantity: "))

cur.execute("SELECT * FROM book_details WHERE Bookid= %s", (Book_id,))


book = cur.fetchone()

if not book:
print("Book not found.")
elif book[4] < quantity:
print("Not enough stock available.")
else:
total_price = book[3] * quantity
cur.execute('''UPDATE book_details SET
Quantity = Quantity - %s WHERE book_id = %s''',
(quantity, book_id))
Db.commit()
print(f'''You have successfully bought {quantity} copies of '{book[1]}'
. Total price: ₹{total_price:.2f}''')

cur.close()
Db.close()
Welcome at e-Bookstore
OUTPUT
A)SIGN Up
B)log in
Enter your choice: A
enter username: simran
enter password: xyz789
Sign up successfully
Select your preferences
1. Add book
2. Search a book
3. View all book details
4. Update book details
5. Delete book details
6. Buy a book
7. Exit
Option 1: Add Book
Input:
Enter book id: 11
Enter book name: The Psychology of Money
Enter its category: Non-Fiction
Enter quantity: 15
Enter price: 499.00

Output:

🔹
(Book added silently, you can confirm via DISPLAY option.)
Option 2: Search Book

Input:
1. search by book id
Enter bookid you want to search: 1
Output:
[(1, 'The Great Gatsby', 'Fiction', 12, 299.99)]

Input:

2. search by bookname
enter book name: The Hobbit
Output:
Record found: [(5, 'The Hobbit', 'Fantasy', 20, 399.99)]

🔹 Option 3: View All Book Details


BookID BName Genre Quantity Price
--------------------------------------------------------------------------------
1 The Great Gatsby Fiction 12 299.99
2 To Kill a Mockingbird Fiction 8 349.5
3 1984 Dystopian 12 199.0
4 The Catcher in the Rye Classic 10 279.75
5 The Hobbit Fantasy 20 399.99
6 Pride and Prejudice Romance 14 250.0
7 The Da Vinci Code Thriller 18 450.0
8 The Alchemist Philosophy 25 199.99
9 Harry Potter and the Sorcerer's Stone Fantasy 30 499.0
10 Sapiens: A Brief History of Humankind Non-Fiction 10 599.0

🔹 Option 4: Update Book Details


Input:
Enter book id you want to change: 3
1. Modify Bookname
2. Modify Price
Enter your choice: 2
Enter new price: 249.00
Updation successfully
🔹 Option 5: Delete Book
Input:
Enter bookid you want to delete: 11
deletion successfully

🔹 Option 6: Buy a Book


Input:
Enter Book ID to buy: 1
Enter quantity: 2
Output:

You have successfully bought 2 copies of 'The Great Gatsby'.


Total price: ₹599.98

🔹 Option 7: Exit
bye bye
BIBLIOGRRAPHY
TO COMPLETE THIS PROJECT FILE, WE HAVE
USED OUR COMPUTER SCIENCE TEXTBOOK
ALONG WITH FOLLOWING WEBSITES:

 www.google.com

 www.youtube.com

 Chatgpt.com

 Scribd.com

The end

You might also like