0% found this document useful (0 votes)
2 views17 pages

Cs Project File-3

The document certifies that Akanksha Singh has completed a Computer Science project on Agro-Food Industry Management System under the guidance of Mrs. Rani Tiwari. It includes an index of sections such as project introduction, code, and output, along with a Python code implementation for managing products, suppliers, and orders in a MySQL database. The project also features functionalities for adding, displaying, searching, and exporting data related to the agro-food industry.

Uploaded by

mangoadapple
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views17 pages

Cs Project File-3

The document certifies that Akanksha Singh has completed a Computer Science project on Agro-Food Industry Management System under the guidance of Mrs. Rani Tiwari. It includes an index of sections such as project introduction, code, and output, along with a Python code implementation for managing products, suppliers, and orders in a MySQL database. The project also features functionalities for adding, displaying, searching, and exporting data related to the agro-food industry.

Uploaded by

mangoadapple
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

ARMY PUBLIC SCHOOL, KHADAKWASLA

CERTIFICAT
This is to certify that,
E
AKANKSHA SINGH of Class XII A Under Board Roll No _________ _has successfully
completed the Computer Science investigatory Project on Agro-Food Industry
Management System for the Session 2023-2024 under the guidance of Mrs. Rani Tiwari
PGT(Computer Science).

___________________ ___________________

SUBJECT TEACHER PRINCIPAL

___________________

EXTERNAL EXAMINER
INDEX
1. Certificate
2. Acknowledgement
3. Requirements
4. Project Introduction
5. Overview
6. Project code
7. Need for the project
8. Future scope of the project
9. Limitations of the project
10. Output
11. Conclusion
12. Bibliography
PROJECT CODE
import mysql.connector

# Initialize the MySQLCONNECTOR database or connect to an existing one


conn = mysql.connector.connect(host="localhost", user="root", passwd="password",
database="AGRO")
if conn.is_connected():
cursor = conn.cursor()

# Create tables if they don't exist


cursor.execute('''
CREATE TABLE IF NOT EXISTS products (
id INTEGER PRIMARY KEY,
product_id TEXT,
product_name TEXT,
product_price REAL
)
''')

cursor.execute('''
CREATE TABLE IF NOT EXISTS suppliers (
id INTEGER PRIMARY KEY,
supplier_id TEXT,
supplier_name TEXT,
supplier_contact TEXT
)
''')

cursor.execute('''
CREATE TABLE IF NOT EXISTS orders (
id INTEGER PRIMARY KEY,
order_id TEXT,
product_id TEXT,
quantity INTEGER,
order_date DATE
)
''')

conn.commit()

def add_product():
print("\n=== Add Product ===")
product_id = input("Enter Product ID: ")
product_name = input("Enter Product Name: ")
product_price = float(input("Enter Product Price: "))

cursor.execute("INSERT INTO products (product_id, product_name, product_price)


VALUES(%s, %s, %s)",
(product_id, product_name, product_price))
conn.commit()
print("\nProduct added successfully!")

def add_supplier():
print("\n=== Add Supplier ===")
supplier_id = input("Enter Supplier ID: ")
supplier_name = input("Enter Supplier Name: ")
supplier_contact = input("Enter Supplier Contact: ")

cursor.execute("INSERT INTO suppliers (supplier_id, supplier_name,


supplier_contact) VALUES (%s, %s, %s)",
(supplier_id, supplier_name, supplier_contact))
conn.commit()
print("\nSupplier added successfully!")

def place_order():
print("\n=== Place Order ===")
order_id = input("Enter Order ID: ")
product_id = input("Enter Product ID: ")
quantity = int(input("Enter Quantity: "))
order_date = input("Enter Order Date: ")

cursor.execute("INSERT INTO orders (order_id, product_id, quantity,


order_date) VALUES (%s, %s, %s, %s)",
(order_id, product_id, quantity, order_date))
conn.commit()
print("\nOrder placed successfully!")

def display_products():
print("\n=== List of Products ===")
cursor.execute("SELECT * FROM products")
for row in cursor.fetchall():
print(f"ID: {row[0]}, Product ID: {row[1]}, Name: {row[2]}, Price:
{row[3]}")

def display_suppliers():
print("\n=== List of Suppliers ===")
cursor.execute("SELECT * FROM suppliers")
for row in cursor.fetchall():
print(f"ID: {row[0]}, Supplier ID: {row[1]}, Name: {row[2]}, Contact:
{row[3]}")

def display_orders():
print("\n=== List of Orders ===")
cursor.execute("SELECT * FROM orders")
for row in cursor.fetchall():
print(f"ID: {row[0]}, Order ID: {row[1]}, Product ID: {row[2]}, Quantity:
{row[3]}, Order Date: {row[4]}")

def search_product_by_name():
print("\n=== Search Product by Name ===")
search_name = input("Enter the Product Name to search: ")

cursor.execute("SELECT * FROM products WHERE product_name LIKE %s", ('%' +


search_name + '%',))
results= cursor.fetchall()

if results:
for row in results:
print(f"ID: {row[0]}, Product ID: {row[1]}, Name: {row[2]}, Price:
{row[3]}")
else:
print("Product not found.")

def export_orders_to_csv():
print("\n=== Export Orders to CSV ===")
cursor.execute("SELECT * FROM orders")
orders = cursor.fetchall()

with open("agro_food_company_orders.csv", "w", newline="") as csvfile:


import csv
writer = csv.writer(csvfile)
writer.writerow(["ID", "Order ID", "Product ID", "Quantity", "Order
Date"])
for row in orders:
writer.writerow([str(row[0]), str(row[1]), str(row[2]), str(row[3]),
str(row[4])])

print("Orders exported to agro_food_company_orders.csv")

def main():
while True:
print("\n==== Agro Food Company Management System ====")
print("1. Add Product")
print("2. Add Supplier")
print("3. Place Order")
print("4. Display Products")
print("5. Display Suppliers")
print("6. Display Orders")
print("7. Search Product by Name")
print("8. Export Orders to CSV")
print("9. Exit")

choice = input("Enter your choice (1/2/3/4/5/6/7/8/9): ")

if choice == '1':
add_product()
elif choice == '2':
add_supplier()
elif choice == '3':
place_order()
elif choice == '4':
display_products()
elif choice == '5':
display_suppliers()
elif choice == '6':
display_orders()
elif choice == '7':
search_product_by_name()
elif choice == '8':
export_orders_to_csv()
elif choice == '9':
print("Exiting the program.")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
OUTPU

MANAGEMENT SYSTEM:

ADDING PRODCTS & DISPLAYING THE

LIST:

ADDING & DISPLAYING LIST OF SUPPLIERS:


PLACING ORDER & LIST OF ORDERS:
SEARCH ORDER BY NAME

EXPORT ORDER TO CSV:

You might also like