Employee Management System
Employee Management System
CERTIFICATE
(Name of the student) bearing Roll Number_ _is the student of Class
It is further certified that this project is the individual and bona fide work of the candidate.
Principal
TIGPS–Bolpur
ACKNOWLEDGEMENT
(name of the project). I would like to express my gratitude towards my teacher, Ms/Mrs./Mr.
under whose guidance and constant
supervision the project has been completed. The instructions and suggestions given by her/him
has been a major contribution towards the completion of the project.
I would also like to thank my parents for their encouragement and support towards completion of
this project work. I also thank my friends for their help and sharing necessary information (and
web links) which helped in preparing the project.
1. Introduction 5
3. Theoretical Background 7
5. System Implementation
Database Design: 17
Outputs of System: 23
7. User Manual 24
8. References 25
4
1. Introduction
purpose of the software project is to develop the Management Information System (MIS)
a particular subject or purpose, capable to produce different reports relevant to the user.
An application program is tied with the database for easy access and interface to the
database. Using Application program or front-end, we can store, retrieve and manage all
This software, being simple in design and working, does not require much of training to
users, and can be used as a powerful tool for automating Employee Management
System.
During coding and design of the software Project, Python, a powerful front-end tool is
used. As a back-end a powerful, open source RDBMS, My SQL is used as per requirement
5
2. Objective & Scope of the Project
To provide a user friendly, Graphical User Interface (GUI) based integrated and
centralized database based on client-server architecture for MIS activities.
The proposed system should maintain all the records and transactions, and should
generate the required reports and information when required.
To identify the critical operation procedure and possibilities of simplification using
modern IT tools and practices.
In its current scope, the software enables user to retrieve and update the information
from centralized database designed with MySQL. This software does not require much
training time of the users due to limited functionality and simplicity.
During the development of this project, Python, a powerful, open source event-
driven form-based development environment is used for modular design and future
expandability of the system.
Despite of the best effort of the developer, the following limitations and functional
boundaries are visible, which limits the scope of this application software.
1. This software can store records and produce reports in pre-designed format in soft
copy. There is no facility yet to produce customized reports. Only specified reports
are covered. So far as future scope of the project is concerned, firstly it is open to
any modular expansion i.e. other modules or functions can be designed and
embedded to handle the user need in future. Any part of the software and reports
can be modified independently without much effort.
6
3. Theoretical Background
What is Database?
A table is a collection of data about a specific topic, such as products or suppliers. Using a
separate table for each topic means you can store that data only once, which makes your
database more efficient and reduces data-entry errors. Table organises data into columns
(called fields) and rows (called records).
A Primary key is one or more fields whose value or values uniquely identify each record
in a table. In a relationship, a primary key is used to refer to specific record in one table
from another table. A primary key is called foreign key when it is referred to from
another table.
To find and retrieve just the data that meets conditions you specify, including data from
multiple tables, create a query. A query can also update or delete multiple records at the
same time, and perform built-in or custom calculations on your data.
7
purpose software package called a Database Management System (DBMS). Some
commercially available DBMS are MS SQL Server, MS ACCESS, INGRES, ORACLE, and
Sybase. A database management system, therefore, is a combination of hardware and
software that can be used to set up and monitor a database, and can manage the updating
and retrieval of database that has been stored in it. Most of the database management
systems have the following capabilities:
What is My SQL?
MySQL, the most popular Open Source SQL database management system, is developed,
distributed, and supported by Oracle Corporation. MySQL is named after co-founder
Monty Widenius's daughter, My. The name of the MySQL Dolphin (our logo) is ―Sakila‖.
8
MySQL is based on SQL.
A relational database stores data in separate tables rather than putting all the data
in one big storeroom. This adds speed and flexibility. The SQL part of ―MySQL‖
stands for ―Structured Query Language.‖ SQL is the most common standardized
language used to access databases and is defined by the ANSI/ISO SQL Standard.
The SQL standard has been evolving since 1986 and several versions exist. In this
manual, ―SQL-92‖ refers to the standard released in 1992, ―SQL: 1999‖ refers to the
standard released in 1999, and ―SQL: 2003‖ refers to the current version of the
standard.
MySQL software is Open Source.
Open Source means that it is possible for anyone to use and modify the software.
Anybody can download the MySQL software from the Internet and use it without
paying anything. If you wish, you may study the source code and change it to suit
your needs. The MySQL software uses the GPL (GNU General Public License),
The MySQL Database Server is very fast, reliable, and easy to use.
If that is what you are looking for, you should give it a try. MySQL Server also has a
practical set of features developed in close cooperation with our users. You can
find a performance comparison of MySQL Server with other database managers on
our benchmark page. MySQL Server was originally developed to handle large
databases much faster than existing solutions and has been successfully used in
highly demanding production environments for several years. Although under
constant development, MySQL Server today offers a rich and useful set of
functions. Its connectivity, speed, and security make MySQL Server highly suited
for accessing databases on the Internet.
MySQL Server works in client/server or embedded systems.
The MySQL Database Software is a client/server system that consists of a multi-
threaded SQL server that supports different backends, several different client
programs and libraries, administrative tools, and a wide range of application
programming interfaces (APIs).
9
Provides the server as a separate program for use in a client/server networked
environment, and as a library that can be embedded (linked) into standalone
applications. Such applications can be used in isolation or in environments where
no network is available.
Password security by encryption of all password traffic when you connect to
a server.
Support for large databases. We use MySQL Server with databases that contain
50 million records. We also know of users who use MySQL Server with 200,000
tables and about 5,000,000,000 rows.
MySQL client programs can be written in many languages. A client library written
in C is available for clients written in C or C++, or for any language that provides C
bindings.
APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl are available,
enabling MySQL clients to be written in many languages.
The Connector/ODBC (MyODBC) interface provides MySQL support for client
programs that use ODBC (Open Database Connectivity) connections.
The Connector/J interface provides MySQL support for Java client programs that
use JDBC connections. Clients can be run on Windows or Unix. Connector/J source
is available.
What is Python?
It provides rich data types and easier to read syntax than any other
programming languages
It is a platform independent scripted language with full access to operating
system API's
Compared to other programming languages, it allows more run-time flexibility
It includes the basic text manipulation facilities of Perl and Awk
A module in Python may have one or more classes and free functions
Libraries in Pythons are cross-platform compatible with Linux, Macintosh,
and Windows
For building large applications, Python can be compiled to byte-code
Python supports functional and structured programming as well as OOP
10
It supports interactive mode that allows interacting Testing and debugging
of snippets of code
In Python, since there is no compilation step, editing, debugging and testing is fast.
NumPy in Python
What is NumPy?
NumPy is a general-purpose array-processing package. It provides a high-performance
multidimensional array object, and tools for working with these arrays.
It is the fundamental package for scientific computing with Python. It contains various
features including these important ones:
It is a table of elements (usually numbers), all of the same type, indexed by a tuple of
positive integers.
NumPy‘s array class is called ndarray. It is also known by the alias array.
For example, you can create an array from a regular Python list or tuple using
the array function. The type of the resulting array is deduced from the type of the
elements in the sequences.
Often, the elements of an array are originally unknown, but its size is known. Hence,
NumPy offers several functions to create arrays with initial placeholder content. These
11
minimize the necessity of growing arrays, an expensive operation.
For example: np.zeros, np.ones, np.full, np.empty, etc.
arange: returns evenly spaced values within a given interval. step size is specified.
linspace: returns evenly spaced values within a given interval. num no. of elements
are returned.
Reshaping array: We can use reshape method to reshape an array. Consider an array
with shape (a1, a2, a3, …, aN). We can reshape and convert it into another array with
shape (b1, b2, b3, …, bM). The only required condition is:
a1 x a2 x a3 … x aN = b1 x b2 x b3 … x bM . (i.e original size of array remains unchanged.)
Slicing: Just like lists in python, NumPy arrays can be sliced. As arrays can be
multidimensional, you need to specify a slice for each dimension of the array.
Integer array indexing: In this method, lists are passed for indexing for each dimension.
One to one mapping of corresponding elements is done to construct a new arbitrary
array.
Boolean array indexing: This method is used when we want to pick elements from array
which satisfy some condition.
Pandas in Python
Pandas has so many uses that it might make sense to list the things it can't do instead of
what it can do.
This tool is essentially your data‘s home. Through pandas, you get acquainted with your
data by cleaning, transforming, and analyzing it.
For example, say you want to explore a dataset stored in a CSV on your computer.
Pandas will extract the data from that CSV into a DataFrame — a table, basically — then
let you do things like:
12
What's the average, median, max, or min of each column?
Does column A correlate with column B?
What does the distribution of data in column C look like?
Clean the data by doing things like removing missing values and filtering rows or
columns by some criteria
Visualize the data with help from Matplotlib. Plot bars, lines, histograms, bubbles,
and more.
Store the cleaned, transformed data back into a CSV, other file or database
Before you jump into the modeling or the complex visualizations you need to have a
good understanding of the nature of your dataset and pandas is the best avenue through
which to do that.
13
4. Python – MySQL Connectivity
We need to know the following detail of the MySQL server to perform the connection
from Python.
Username – i.e., the username that you use to work with MySQL Server. The
default username for the MySQL database is a root
Password – Password is given by the user at the time of installing the MySQL
database. If you are using root then you won‘t need the password.
Host Name – is the server name or Ip address on which MySQL is running. if you
are running on localhost, then you can use localhost, or it‘s IP, i.e. 127.0.0.0
Database Name – Database name to which you want to connect. Here we are using
Database named ‗Electronics‗ because we have already created this for our
example.
Note: We are using the MySQL Connector Python module to communicate with MySQL
import mysql.connector
This line imports the MySQL Connector Python module in your program so you can use
this module‘s API to connect MySQL.
mysql.connector.connect()
Using this method we can connect the MySQL Database, this method accepts four
required parameters: Host, Database, User and Password that we already
discussed.
connect() method established a connection to the MySQL database from Python
application and returned a MySQLConnection object. Then we can use
MySQLConnection object to perform various operations on the MySQL Database.
14
The Connect() method can throw an exception, i.e. Database error if one of the
required parameters is wrong. For example, if you provide a database name that
is not present in MySQL, then Python application throws an exception. So check
the arguments that you are passing to this method.
connection.is_connected( )
is_connected() is the method of the MySQLConnection class through which we can verify
is our python application connected to MySQL.
connection.cursor( )
This method returns a cursor object. Using a cursor object, we can execute SQL queries.
The MySQLCursor class instantiates objects that can execute operations such as SQL
statements.
Cursor objects interact with the MySQL server using a MySQLConnection object.
cursor.close()
Using the cursor‘s close method we can close the cursor object. Once we close the cursor
object, we cannot execute any SQL statement.
connection.close()
At last, we are closing the MySQL database connection using a close() method of
MySQLConnection class.
15
5. System Implementation
16
6. System Design & Development
The idea is that we perform different changes in our Employee Record by using different
functions for example the Add_Employee will insert a new row in our Employee, also,
we will create a Remove Employee Function which will delete the record of any
particular existing employee in our Employee table. This System works on the concepts
of taking the information from the database making required changes in the fetched data
and applying the changes in the record which we will see in our Promote Employee
System. We can also have the information about all the existing employees by using the
Display Employee function. The main advantage of connecting our program to the
database is that the information becomes lossless even after closing our program a
number of times.
Database Design
For creating the Employee Management System in Python that uses MySQL database we
need to connect Python with MySQL.
For making a connection we need to install mysqlconnector which can be done by
writing the following command in the command prompt on Windows.
Now after successful installation of mysqlconnector we can connect MySQL with Python
which can be done by writing the following code
import mysql.connector
con = mysql.connector.connect(
host="localhost", user="root", password="password", database="emp")
Now we are done with the connections, so we can focus on our Employee Management
System.
Table in Use:
17
Coding for System Design
The idea is that we keep all the information about the Employee in the above table and
manipulate the table whenever required. So now we will look at the working of each
operation in detail.
Program:
# Function To Check if Employee with
# given Id Exist or Not
def check_employee(employee_id):
# Query to select all Rows f
# rom employee Table
sql = 'select * from empd where id=
%s' # making cursor buffered to make
# rowcount method work
properly c =
con.cursor(buffered=True) data =
(employee_id,)
# Executing the SQL Query
c.execute(sql, data)
# rowcount method to find
# number of rows with given
values r = c.rowcount
if r = = 1:
return True
else:
return False
18
Program:
# Function to mAdd_Employee
def Add_Employ():
Id = input("Enter Employee Id : ")
# Checking if Employee with given Id
# Already Exist or Not
if(check_employee(Id) = = True):
print("Employee aready 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)
# Inserting Employee details in the Employee
# Table
sql = 'insert into empd values(%s,%s,%s,%s)'
c = con.cursor()
# Executing the SQL Query
c.execute(sql, data)
# commit() method to make changes in the table
con.commit()
print("Employee Added Successfully ")
menu()
Program
# Function to Remove Employee with given Id
def Remove_Employ():
Id = input("Enter Employee Id : ")
# Checking if Employee with given Id
# Exist or Not
if(check_employee(Id) == False):
print("Employee does not exists\nTry Again\n")
menu()
19
else:
# Query to Delete Employee from
Table sql = 'delete from empd where
id=%s' data = (Id,)
c = con.cursor()
# Executing the SQL Query
c.execute(sql, data)
# commit() method to make changes in
# the table
con.commit()
print("Employee Removed")
menu()
Program
# Function to Promote Employee
def Promote_Employee():
Id = int(input("Enter Employ's Id"))
# Checking if Employee with given Id
# Exist or Not
if(check_employee(Id) == False):
print("Employee does not exists\nTry Again\n")
menu()
else:
Amount = int(input("Enter increase in Salary"))
# Query to Fetch Salary of Employee with
# given Id
sql = 'select salary from empd where id=%s'
data = (Id,)
c = con.cursor()
# Executing the SQL Query
c.execute(sql, data)
# Fetching Salary of Employee with given Id
r = c.fetchone()
t = r[0]+Amount
# Query to Update Salary of Employee with
# given Id
sql = 'update empd set salary=%s where id=%s'
d = (t, Id)
# Executing the SQL Query
20
c.execute(sql, d)
# commit() method to make changes in the table
con.commit()
print("Employee Promoted")
menu()
Program:
# Function to Display All Employees
# from Employee Table
def Display_Employees():
# query to select all rows from
# Employee Table
sql = 'select * from empd'
c = con.cursor()
# Executing the SQL Query
c.execute(sql)
# Fetching all details of all the
# Employees
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
# menu function to display the menu
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")
21
print("4 to Display Employees")
print("5 to Exit")
# Taking choice from user
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()
22
Output of System
Screen 1
Screen 2
23
7. User Manual
How to install?
Hardware Requirement
Intel Celeron or more upgraded processor based PC at Client/Server end.
Minimum 2 GB RAM and 10 GB HDD space (for Database) is desirable.
Standard I/O devices like Keyboard and Mouse etc.
Printer is needed for hard-copy reports.
Local Area Network(LAN) is required for Client-Server Installation
Software Requirement
Windows 7/10 OS is desirable.
Anaconda Navigator/Jupiter/Spyder should be installed with MySQL and Matplotlib
package.
MySQL Ver 5.1 with Library Database must be present at machine.
Database Installation
The software project is distributed with a backup copy of a Database named Employee
with required tables. Some dummy records are present in the tables for testing purposes,
which can be deleted before inserting real data. The project is shipped with Employee.sql
file which installs a database and tables in the computer system.
Note: The PC must have MySQL server with user (root) and password (root). If root
password is any other password, it can be changed by running MySQL Server Instance
Configure Wizard.
Start Program MySQL MySQL Server MySQL Server Instance Config Wizard Provide
current password of root and new password as ―root‖ , this will change the root
password.
To install a MySQL database from a dump file (Employee.sql), simply follow the
following steps.
Step 1: Copy the Lib.sql file in C:\Program files\Mysql\MySql server 5.1\Bin folder.
Step 2: Open MySQL and type the following command to create the dabase named
Employee.
mysql> create database Employee;
Step 3: Open Command Window (Start Run cmd)
Step 4: Go to the following folder using CD command of DOS.
C:\Program files\Mysql\MySql server 5.1\Bin>
Step 5: type the following command on above prompt
-
C:….\bin>mysql -u root -proot Employee< Employee.sql>
This will create a Employee databse with required tables.
24
8. References
In order to work on this project titled ―Employee Management System‖, the following
books and literature are referred by me during the various phases of development of the
project.
(4)http://www.python.org/
Other than the above mentioned books, the suggestions and supervision of my
teacher and my class experience also helped me to develop this software project.
25