Computer Science Project Draft
Computer Science Project Draft
CONTENTS
1
SYNOPSIS
2
SAMPLE CODE
3
SAMPLE CODE
import mysql.connector
mydb = mysql.connector.connect(
host="localhost", user="root", password="viproad"
)
while True:
print("1: Signup\n2: Login")
ch = int(input("SIGNUP/LOGIN (1,2):"))
# SIGNUP
if ch == 1:
username = input("USERNAME: ")
pw = input("PASSWORD: ")
mycursor.execute("INSERT INTO signup (username, password)
VALUES (%s, %s)", (username, pw))
mydb.commit()
4
# LOGIN
elif ch == 2:
username = input("USERNAME: ")
mycursor.execute("SELECT username FROM signup WHERE
username = %s", (username,))
pot = mycursor.fetchone()
if a is not None:
print("++++++++++++++++++++++++\n+++ LOGIN
SUCCESSFUL +++\n++++++++++++++++++++++++")
print("""
=====================================================
=======
+++++++++++++++ WELCOME TO B.S. BOOK STORE ++++++++++
++++++
=====================================================
=======
""")
mycursor.execute("""
CREATE TABLE IF NOT EXISTS Available_Books (
BookName VARCHAR(30) PRIMARY KEY,
Genre VARCHAR(20),
Quantity INT(3),
5
Author VARCHAR(20),
Publication VARCHAR(30),
Price INT(4)
)
""")
mycursor.execute("""
CREATE TABLE IF NOT EXISTS Sell_rec (
CustomerName VARCHAR(20),
PhoneNumber CHAR(10) UNIQUE,
BookName VARCHAR(30),
Quantity INT(100),
Price INT(4),
FOREIGN KEY (BookName) REFERENCES
Available_Books(BookName)
)
""")
mycursor.execute("""
CREATE TABLE IF NOT EXISTS Staff_details (
Name VARCHAR(30),
Gender VARCHAR(10),
Age INT(3),
PhoneNumber CHAR(10) UNIQUE,
Address VARCHAR(40)
)
""")
mydb.commit()
while True:
print("""
1: Add Books
2: Delete Books
3: Search Books
6
4: Staff Details
5: Sell Record
6: Available Books
7: Total Income after the Latest Reset
8: Exit
""")
a = int(input("Enter your choice:"))
# ADD BOOKS
if a == 1:
print("All information prompted is mandatory.")
book = input("Enter Book Name: ")
genre = input("Genre: ")
quantity = int(input("Enter quantity: "))
author = input("Enter author name: ")
publication = input("Enter publication house: ")
price = int(input("Enter the price: "))
# DELETE BOOKS
elif a == 2:
print("AVAILABLE BOOKS...")
mycursor.execute("SELECT * FROM Available_Books")
for x in mycursor:
print(x)
else:
print("++++++++++++++++++++++++++\n++ INCORRECT
PASSWORD ++\n++++++++++++++++++++++++++")
else:
print("++++++++++++++++++++++++++\n++ INVALID
USERNAME ++\n++++++++++++++++++++++++++")
else:
break
9
OUTPUT SCREEN
10
OUTPUT SCREEN
➔ If the user selects 1, they will see a prompt for a username and
password.
➔ If the user selects 2, they will be asked to provide their username and
password for login.
2. Signup Successful:
3. Login Succes:
11
4. Main Menu Screen:
12
7. Search Books Screen:
The user will choose the search method from the following options:
If searching by name:
13
If adding a new staff member:
If removing staff:
14
Incorrect Password:
Summary:
● After login, the system displays a menu where users can manage
books, staff, sell records, and reports.
● User-friendly prompts are shown for each operation.
● Success messages are displayed after each successful operation, while
invalid inputs result in error messages.
15
BIBLIOGRAPHY
16
BIBLIOGRAPHY
Internet:
www.google.com
www.slideshare.net
Books:
COMPUTER SCIENCE CLASS 12 Book (SUMITA ARORA).
17