Professional Documents
Culture Documents
Employee Management
Employee Management
Employee Management
SYSTEM
GROUP MEMBERS :
SANJAY.V
IRIN MARIAM SANU
INTRODUCTION
● Secure data
● Faster process
● Error Free
● Better management
● Save a lot of manpower
● Can easily make the daily reports
● Elimination of Paper work.
● High reliability and security.
● Fast and economical.
MODULE USED
MYSQLCONNECTOR
MySQL Connector/Python is a pure-Python MySQL driver that provides a
Pythonic interface to MySQL databases. It is the official MySQL driver for
Python, and it is compatible with all versions of MySQL from 5.0 and up.
It can be used with any Python application that uses the standard DB-API.
MySQL Connector/Python is a versatile tool that can be used for a wide
variety of applications, including:
Developing web applications: MySQL Connector/Python can be used
to connect to MySQL databases from web applications written in
Python.
Data analysis: MySQL Connector/Python can be used to connect to
MySQL databases making it easy to extract and analyze data from
MySQL databases.
MySQL Connector/Python is a powerful and easy-to-use tool that is
essential for any Python developer who needs to work with MySQL
databases.
Here are some of the benefits of using MySQL Connector/Python:
Pure Python: MySQL Connector/Python is written in pure Python,
which means that it does not require any C extensions. This makes it
easy to install and use, and it also makes it more portable than other
MySQL drivers.
Feature-rich: MySQL Connector/Python supports a wide range of
features, including prepared statements, stored procedures, and
binary data.
Well-maintained: MySQL Connector/Python is actively maintained by
a team of developers, and it is regularly updated with new features
and bug fixes
SOURCE CODE
GETTING STARTED
import mysql.connector
con=mysql.connector.connect(host="localhost",
user="root", password="password", database="emp")
CHECK EMPLOYEE FUNCTION
The check employee function takes employee id as a parameter and
checks whether any employee with given id exists in the employee
details record or not. For checking this it uses cursor.rowcount()
function which counts the number of rows that match with given
details. It is a utility function, and we will see its use in later
operations like Add employee function, etc.
Program:
def check_employee(employee_id):
sql = 'select * from empd where id=%s'
c = con.cursor(buffered=True)
data = (employee_id,)
c.execute(sql, data)
r = c.rowcount
if r == 1:
return True
else:
return False
ADD EMPLOYEE FUNCTION
The Add Employee function will ask for the Employee Id and uses
the check employee function to check whether the employee to be
added already exist in our record or not if employee details do not
already exist then it asks for details of the employee to be added
like Employee Name, Post of Employee and Salary of the employee.
Now after getting all such details from the user of that system it
simply inserts the information in our Employee details table.
Program:
# Function to mAdd_Employee
def Add_Employ():
Id = input("Enter Employee Id : ")
if(check_employee(Id) == True):
print("Employee already exists\nTry Again\n")
menu()
else:
Name = input("Enter Employee Name : ")
Post = input("Enter Employee Post : ")
Salary = input("Enter Employee Salary : ")
data = (Id, Name, Post, Salary)
sql = 'insert into empd values(%s,%s,%s,%s)'
c = con.cursor()
c.execute(sql, data)
con.commit()
print("Employee Added Successfully ")
menu()
REMOVE EMPLOYEE FUNCTION
The Remove Employee Function will simply ask for Id of the
employee to be removed because Id is Primary key in our Employee
Details Record as there can be two employees with the same name,
but they must have a unique id. The Remove Employee function
uses the check employee function to check whether the employee
to be removed exists in our record or not if employee details exist
then after getting a valid employee id it deletes the record
corresponding to that employee id.
Program:
def Remove_Employ():
Id = input("Enter Employee Id : ")
if(check_employee(Id) == False):
print("Employee does not exists\nTry Again\n")
menu()
else:
sql = 'delete from empd where id=%s'
data = (Id,)
c = con.cursor()
c.execute(sql, data)
con.commit()
print("Employee Removed")
menu()
PROMOTE EMPLOYEE FUNCTION
The Promote Employee function will ask for the Employee Id and
uses the check employee function to check whether the employee
to be Promoted exist in our record or not if employee details exist
then it will ask for the amount by which his salary is to be
increased. After getting the valid details it increases the salary of
the employee with the given id by the given amount.
Program:
def Promote_Employee():
Id = int(input("Enter Employ's Id"))
if(check_employee(Id) == False):
print("Employee does not exists\nTry Again\n")
menu()
else:
Amount = int(input("Enter increase in Salary"))
sql = 'select salary from empd where id=%s'
data = (Id,)
c = con.cursor()
c.execute(sql, data)
r = c.fetchone()
t = r[0]+Amount
sql = 'update empd set salary=%s where id=%s'
d = (t, Id)
c.execute(sql, d)
con.commit()
print("Employee Promoted")
menu()
DISPLAY EMPLOYEES FUNCTION
The Promote Employee function will ask for the Employee Id and
uses the check employee function to check whether the employee
to be Promoted exist in our record or not if employee details exist
then it will ask for the amount by which his salary is to be
increased. After getting the valid details it increases the salary of
the employee with the given id by the given amount.
Program:
def Display_Employees():
sql = 'select * from empd'
c = con.cursor()
c.execute(sql)
r = c.fetchall()
for i in r:
print("Employee Id : ", i[0])
print("Employee Name : ", i[1])
print("Employee Post : ", i[2])
print("Employee Salary : ", i[3])
print("-----------------------------\
-------------------------------------\
-----------------------------------")
menu()
MENU FUNCTION
The Menu function displays the menu to the user and asks the user
to enter his choice for performing operations like Add employee,
Remove employee, etc.
Program :
def menu():
print("Welcome to Employee Management Record")
print("Press ")
print("1 to Add Employee")
print("2 to Remove Employee ")
print("3 to Promote Employee")
print("4 to Display Employees")
print("5 to Exit")
ch = int(input("Enter your Choice "))
if ch == 1:
Add_Employ()
elif ch == 2:
Remove_Employ()
elif ch == 3:
Promote_Employee()
elif ch == 4:
Display_Employees()
elif ch == 5:
exit(0)
else:
print("Invalid Choice")
menu()
BIBLIOGRAPHY
Computer science With Python - Class XI By: Sumita Arora
ChatGPT
GitHub.com
www.geeksforgeeks.org