Vai Project Edited 3 Fin
Vai Project Edited 3 Fin
1 Acknowledgement 1
2 Introduction 2
3 User Manual 3
5 Source Code 5
6 Output 11
7 Limitations 18
8 Bibliography 19
Acknowledgement
I also want to thank our Principal, Sr Melissa and all the staff at
Mount Carmel Central School, for providing me with the required
facilities.
1
Introduction
2
User Manual
1. Exploring Categories
2. Selling Items
3. Buying Items
4. Exiting KR MART
1. Exploring Categories:
• Display Items by Category:
• To view items available in different categories, select option "1."
• Explore diverse categories like Electronics, Clothing, Books,
Home Appliances, and Sports.
2. Selling Items:
• Sell Item:
• To list an item for sale, choose option "2."
• Enter the item's name, price, and select the relevant category.
3. Buying Items:
• Display Items and Buy:
• To view and purchase items, select option "3."
• Enter the number of the category to display items, then follow the
prompts to buy the desired item.
4. Exiting KR MART:
• Quit:
• To exit KR MART, choose option "4."
• Thank you for using KR MART! Your digital shopping destination
awaits.
3
Hardware and Software Requirements
4
Source Code
import mysql.connector
# MySQL configuration
db_config = {
'host': 'localhost',
'user': 'root',
'password': '12345',
'database': 'marketplace'
}
def display_items_by_category(category_table):
connection = get_mysql_connection()v v
vf
cursor = connection.cursor()
cursor.execute(f"SELECT * FROM {category_table}")
items = cursor.fetchall()
cursor.close()
connection.close()
if not items:
print(f"\nNo items found in the '{category_table}' category.")
else:
print(f"\n{category_table.capitalize()} Items:")
print("ID\tName\t\tPrice (₹)")
print("-" * 40)
for item in items:
print(f"{item[0]}\t{item[1]}\t\t₹{item[2]:,.2f}")
5
def buy_item(category_table):
user_choice = int(input("Enter the ID of the item you want to buy: "))
connection = get_mysql_connection()
cursor = connection.cursor()
cursor.execute(f"SELECT * FROM {category_table} WHERE id = %s",
(user_choice,))
item = cursor.fetchone()
if item:
# Deduct user's balance and update product status
cursor.execute(f"DELETE FROM {category_table} WHERE id = %s",
(user_choice,))
connection.commit()
cursor.close()
connection.close()
print(f"\nYou have purchased '{item[1]}' for ₹{item[2]:,.2f}.")
else:
cursor.close()
connection.close()
print("\nProduct not found.")
def main():
while True:
print("\nOptions:")
print("1. Display Items by Category")
print("2. Sell Item")
print("3. Buy Item")
print("4. Exit")
if choice == '1':
display_items_by_category('electronics')
display_items_by_category('clothing')
display_items_by_category('books')
display_items_by_category('home_appliances')
display_items_by_category('sports')
elif choice == '2':
name = input("Enter the name of the item: ")
price = float(input("Enter the price of the item (₹): "))
print("\nCategories:")
print("1. Electronics")
print("2. Clothing")
print("3. Books")
print("4. Home Appliances")
print("5. Sports")
category_choice = int(input("Enter the number of the category for
the item: "))
6
if category_choice == 1:
sell_item(name, price, 'electronics')
elif category_choice == 2:
sell_item(name, price, 'clothing')
elif category_choice == 3:
sell_item(name, price, 'books')
elif category_choice == 4:
sell_item(name, price, 'home_appliances')
elif category_choice == 5:
sell_item(name, price, 'sports')
else:
print("\nInvalid category number. Item not listed.")
elif choice == '3':
print("\nCategories:")
print("1. Electronics")
print("2. Clothing")
print("3. Books")
print("4. Home Appliances")
print("5. Sports")
category_choice = int(input("Enter the number of the category to
display items: "))
if category_choice == 1:
display_items_by_category('electronics')
buy_item('electronics')
elif category_choice == 2:
display_items_by_category('clothing')
buy_item('clothing')
elif category_choice == 3:
display_items_by_category('books')
buy_item('books')
elif category_choice == 4:
display_items_by_category('home_appliances')
buy_item('home_appliances')
elif category_choice == 5:
display_items_by_category('sports')
buy_item('sports')
else:
print("\nInvalid category number. Please try again.")
elif choice == '4':
break
else:
print("\nInvalid choice. Please try again.")
if __name__ == '__main__':
main()
7
8
9
10
Output
11
12
13
14
15
16
17
Limitations
• Limited Interactivity:
The current implementation relies on a console-based interface, limiting
the interactive and visual aspects of the user experience.
• Single-User Interaction:
The application is designed for a single user at a time. Implementing
features for multiple users concurrently interacting with the
marketplace could enhance the project.
18
Bibliography
19