Dairy
Dairy
1
2. Data-Driven Decisions: Access to real-time data and historical records
empowers farmers to make informed decisions based on trends and
analytics.
3. Cost Reduction: By optimizing milk production and inventory
management, farmers can reduce waste and lower operational costs.
4. Enhanced Animal Health: Regular monitoring of animal health and
production data leads to better care and increased milk yield.
5. Scalability: As the farm grows, the system can be expanded to
accommodate more animals, employees, and inventory items without a
significant overhaul.
Technologies Used
Conclusion
2
FRONT END: PYTHON
PYTHON:
3
MYSQL:
4
Source Code:
import mysql.connector
def db_connection():
try:
return mysql.connector.connect(
host='localhost',
user='root',
password='admin',
database='dairy_farm'
print(f"Error: {err}")
return None
conn = db_connection()
if conn:
cursor = conn.cursor()
5
cursor.execute("INSERT INTO Cows (name, breed, age, health_status)
VALUES (%s, %s, %s, %s)",
conn.commit()
cursor.close()
conn.close()
else:
def get_cows():
conn = db_connection()
if conn:
cursor = conn.cursor()
cows = cursor.fetchall()
cursor.close()
conn.close()
return cows
return []
6
conn = db_connection()
if conn:
cursor = conn.cursor()
conn.commit()
cursor.close()
conn.close()
else:
def delete_cow(cow_id):
conn = db_connection()
if conn:
cursor = conn.cursor()
conn.commit()
cursor.close()
conn.close()
7
else:
conn = db_connection()
if conn:
cursor = conn.cursor()
conn.commit()
cursor.close()
conn.close()
else:
def get_milk_production():
conn = db_connection()
if conn:
cursor = conn.cursor()
8
cursor.execute("SELECT * FROM Milk_Production")
production = cursor.fetchall()
cursor.close()
conn.close()
return production
return []
conn = db_connection()
if conn:
cursor = conn.cursor()
conn.commit()
cursor.close()
conn.close()
else:
9
def get_employees():
conn = db_connection()
if conn:
cursor = conn.cursor()
employees = cursor.fetchall()
cursor.close()
conn.close()
return employees
return []
def main():
while True:
10
print("8. View Employees")
print("9. Exit")
if choice == '1':
cows = get_cows()
print(cow)
11
age = int(input("Enter new age: "))
delete_cow(cow_id)
production_records = get_milk_production()
print(record)
12
role = input("Enter role: ")
employees = get_employees()
print("Employees:")
print(emp)
break
else:
if __name__ == "__main__":
main()
13
Python Output:
14
15
16
17
18
MYSQL Output:
19
20
21