0% found this document useful (0 votes)
43 views18 pages

Hardware Shop PDF

t

Uploaded by

vithyamithun892
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)
43 views18 pages

Hardware Shop PDF

t

Uploaded by

vithyamithun892
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/ 18

Introduction

In today’s competitive retail environment, efficient management of a


hardware shop is crucial for success. A well-structured management system helps
streamline operations, enhances customer satisfaction, and improves inventory
control. This project aims to create a Hardware Shop Management System using
Python and MySQL, providing essential functionalities to manage products,
customers, and sales effectively.

Objectives

1. Product Management: Easily add, update, view, and delete products,


ensuring accurate inventory tracking.
2. Customer Management: Maintain customer records to enhance
personalized service and track sales.
3. Sales Management: Record and manage sales transactions while ensuring
inventory levels are updated in real time.
4. Reporting: Generate reports to analyze sales and inventory trends, aiding in
decision-making.

Key Features

 User-Friendly Interface: A command-line interface (CLI) for


straightforward interaction with the system.
 Robust Database Management: MySQL is used to store data securely and
efficiently, allowing for complex queries and relationships.
 Real-Time Updates: Changes in inventory and sales are reflected
immediately, helping avoid stockouts and overstocking.

1
Technology Stack

 Python: The primary programming language for developing the application


logic.
 MySQL: A relational database management system used for data storage.
 MySQL Connector: A Python library that facilitates communication
between the Python application and the MySQL database.

This system serves as a foundational tool for hardware shop owners to manage
their business operations more effectively, ultimately leading to improved
profitability and customer satisfaction. As the project evolves, additional features
can be implemented, such as user authentication, advanced reporting, and a
graphical user interface (GUI).

2
FRONT END: PYTHON
BACK END :MYSQL

PYTHON:
Python is an interpreted, object-oriented, high-level programming language with
dynamic semantics developed by Guido van Rossum. It was originally released in
1991. Designed to be easy as well as fun, the name "Python" is a nod to the British
comedy group Monty Python. Python has a reputation as a beginner-friendly
language, replacing Java as the most widely used introductory language because it
handles much of the complexity for the user, allowing beginners to focus on fully
grasping programming concepts rather than minute details.

Python is used for server-side web development, software development,


mathematics, and system scripting, and is popular for Rapid Application
Development and as a scripting or glue language to tie existing components
because of its high-level, built-in data structures, dynamic typing, and dynamic
binding. Program maintenance costs are reduced with Python due to the easily
learned syntax and emphasis on readability. Additionally, Python's support of
modules and packages facilitates modular programs and reuse of code. Python is
an open source community language, so numerous independent programmers are
continually building libraries and functionality for it.

3
MYSQL:
MySQL is a SQL-based relational database management system for web databases.
Use MySQL for various applications, including data cleansing, data warehousing,
online shopping, logging software, and portals. MySQL can store everything from
a single record to a complete product inventory. The application of MySQL varies
based on the need. It can associate with any scripting language like PHP or Perl
and create websites.

4
Source Code:

import mysql.connector

# Database connection

def get_db_connection():

return mysql.connector.connect(

host='localhost',

user='root',

password='admin',

database='hardware_shop'

# Product Management

def add_product(name, price, quantity):

conn = get_db_connection()

cursor = conn.cursor()

sql = "INSERT INTO products (name, price, quantity) VALUES (%s, %s, %s)"

cursor.execute(sql, (name, price, quantity))

conn.commit()

cursor.close()

conn.close()

print("Product added!")

5
def list_products():

conn = get_db_connection()

cursor = conn.cursor()

cursor.execute("SELECT * FROM products")

products = cursor.fetchall()

cursor.close()

conn.close()

return products

def low_stock_products(threshold=5):

conn = get_db_connection()

cursor = conn.cursor()

cursor.execute("SELECT * FROM products WHERE quantity < %s",


(threshold,))

low_stock = cursor.fetchall()

cursor.close()

conn.close()

return low_stock

# Sales Management

def record_sale(product_id, customer_id, quantity):

6
conn = get_db_connection()

cursor = conn.cursor()

# Check stock

cursor.execute("SELECT quantity FROM products WHERE id = %s",


(product_id,))

product = cursor.fetchone()

if not product or product[0] < quantity:

print("Insufficient stock!")

cursor.close()

conn.close()

return

# Insert sale

sql = "INSERT INTO sales (product_id, customer_id, quantity) VALUES (%s,


%s, %s)"

cursor.execute(sql, (product_id, customer_id, quantity))

# Update product quantity

new_quantity = product[0] - quantity

cursor.execute("UPDATE products SET quantity = %s WHERE id = %s",


(new_quantity, product_id))

7
conn.commit()

cursor.close()

conn.close()

print("Sale recorded!")

# Customer Management

def add_customer(name, contact):

conn = get_db_connection()

cursor = conn.cursor()

sql = "INSERT INTO customers (name, contact) VALUES (%s, %s)"

cursor.execute(sql, (name, contact))

conn.commit()

cursor.close()

conn.close()

print("Customer added!")

def list_customers():

conn = get_db_connection()

cursor = conn.cursor()

cursor.execute("SELECT * FROM customers")

customers = cursor.fetchall()

8
cursor.close()

conn.close()

return customers

# Main Menu

def main():

while True:

print("\n--- Hardware Shop Management ---")

print("1. Add Product")

print("2. List Products")

print("3. List Low Stock Products")

print("4. Record Sale")

print("5. Add Customer")

print("6. List Customers")

print("7. Exit")

choice = input("Select an option: ")

if choice == '1':

name = input("Product Name: ")

price = float(input("Price: "))

quantity = int(input("Quantity: "))

9
add_product(name, price, quantity)

elif choice == '2':

products = list_products()

for product in products:

print(product)

elif choice == '3':

low_stock = low_stock_products()

for product in low_stock:

print(product)

elif choice == '4':

product_id = int(input("Product ID: "))

customer_id = int(input("Customer ID: "))

quantity = int(input("Quantity: "))

record_sale(product_id, customer_id, quantity)

elif choice == '5':

name = input("Customer Name: ")

contact = input("Contact: ")

add_customer(name, contact)

elif choice == '6':

customers = list_customers()

10
for customer in customers:

print(customer)

elif choice == '7':

print("Exiting...")

break

else:

print("Invalid option. Please try again.")

if __name__ == '__main__':

main()

11
Python Output:

12
13
14
15
MYSQL Output:

16
17
18

You might also like