Computer Project
Computer Project
Computer Project
COMPUTER SCIENCE(083)
CERTIFICATE
Certified that this is the bonafide record of project work carried out by
Roll No.
1, Acknowledgment 4
4. Software Requirements 7
5. Coding 11
6. Output 28
2
7. Bibliography 32
3
ACKNOWLEDGEMENT
I WOULD LIKE TO TAKE THIS OPPORTUNITY TO EXPRESS MY THANKS TO MANY OTHERS WHO
HAVE PLAYED A KEY ROLE IN THE SUCCESS OF THIS PROJECT.
I WOULD LIKE TO THANK MY COMPUTER SCIENCE TEACHERS FOR PROVIDING ME WITH ALL THE
GUIDANCE AND TOOLS THAT HAVE BEEN INSTRUMENTAL TO THE COMPLETION OF THIS
PROJECT.
PROJECT.
4
Need For This Project
We all know that our ideas will gain true meaning only if we are practical.
The main motive of this project is to let the people apply their
programming knowledge in the modern world and exposed them how
programming helps in developing a good software.
5
Objectives and Functionality
The basic need for this task is to create an Employee Management System
in Python. The source code will contain the following operations:
Add Employees
Remove Employees
Promote Employees
Display Employees
Search Employee Details
Update Employee Details
6
SOFTWARE REQUIREMENTS
PYTHON
7
at the National Research Institute for Mathematics and Computer Science
in the Netherlands. Python is derived from many other languages,
including ABC, Modula-3, C, C++, Algol-68, SmallTalk, and Unix shell and
Download at - https://www.python.org/downloads/
8
MySQL
MySQL is a fast, easy-to-use RDBMS being used for many small and big
businesses. MySQL is developed, marketed and supported by MySQL AB,
which is a Swedish company. MySQL is becoming so popular because of
many good reasons −
MySQL is released under an open-source license. So you
have nothing to pay to use it.
MySQL is a very powerful program in its own right. It
handles a large subset of the functionality of the most
expensive and powerful database packages.
MySQL uses a standard form of the well-known SQL data
language.
MySQL works on many operating systems and with many
languages including PHP, PERL, C, C++, JAVA, etc.
MySQL works very quickly and works well even with large
data sets.
9
MySQL is very friendly to PHP, the most appreciated
language for web development.
MySQL supports large databases, up to 50 million rows or
more in a table. The default file size limit for a table is 4GB,
but you can increase this (if your operating system can
handle it) to a theoretical limit of 8 million terabytes (TB).
MySQL is customizable. The open-source GPL license allows
programmers to modify the MySQL software to fit their own
specific environments.
10
Coding:
import os
import mysql.connector
#making Connection
con =
mysql.connector.connect(host="localhost",user="root",password="2006"
)
mycursor= con.cursor() #allows row-by-row processing of the result
sets.
mycursor.execute("CREATE DATABASE employee")
import mysql.connector
#making Connection
con = mysql.connector.connect (
host = " localhost " , user = " root " , password = "2006" , database
= " employee " )
mycursor= con.cursor()
mycursor.execute("CREATE TABLE empdata ( Id INT(11) PRIMARY KEY ,
Name VARCHAR(1800),
11
Emial_Id TEXT(1800),Phone_no BIGINT( 11 ), Address TEXT(1000), Post
TEXT(1000), Salary
BIGINT(20))")
# Function to Add_Employee
def Add_Employ():
print("{:>60}".format("-->>Add Employee Record<<--"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if (check_employee(Id) == True):
print("Employee ID Already Exists\nTry Again..")
press = input("Press Any Key To Continue..")
Add_Employ()
Name = input("Enter Employee Name: ")
# checking If Employee Name is Exit Or Not
if (check_employee_name(Name) == True):
print("Employee Name Already Exists\nTry Again..")
press = input("Press Any Key To Continue..")
12
Add_Employ
Email_Id = input("Enter Employee Email ID: ")
press = input("Press Any Key To Continue..")
Add_Employ()
13
# the Employee (empdata) Table
sql = 'insert into empdata values(%s,%s,%s,%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("Successfully Added Employee Record")
press = input("Press Any Key To Continue..")
menu()
# Function To Check if Employee With
# given Name Exist or not
def check_employee_name(employee_name):
# query to select all Rows from
# employee(empdata) table
sql = 'select * from empdata where Name=%s'
# making cursor buffered to make
14
# rowcount method work properly
c = con.cursor(buffered=True)
data = (employee_name,)
# Execute the sql query
c.execute(sql, data)
# rowcount method to find number
# of rowa with given values
r = c.rowcount
if r == 1:
return True
else:
return False
# Function To Check if Employee With
# given Id Exist or not
def check_employee(employee_id):
# query to select all Rows from
# employee(empdata) table
15
sql = 'select * from empdata where Id=%s'
# making cursor buffered to make
# rowcount method work properly
c = con.cursor(buffered=True)
data = (employee_id,)
# Execute the sql query
c.execute(sql, data)
# rowcount method to find number
# of rowa with given values
r = c.rowcount
if r == 1:
return True
else:
return False
def Display_Employ():
print("{:>60}".format("-->> Display Employee Record <<--"))
# query to select all rows from Employee (empdata) Table
16
sql = 'select * from empdata'
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 Email Id: ", i[2])
print("Employee Phone No.: ", i[3])
print("Employee Address: ", i[4])
print("Employee Post: ", i[5])
print("Employee Salary: ", i[6])
print("\n")
press = input("Press Any key To Continue..")
menu()
17
def Update_Employ():
print("{:>60}".format("-->> Update Employee Record <<--\n"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if(check_employee(Id) == False):
print("Employee Record Not exists\nTry Again")
press = input("Press Any Key To Continue..")
menu()
else:
Email_Id = input("Enter Employee Email ID: ")
if(re.fullmatch(regex, Email_Id)):
print("Valid Email")
else:
print("Invalid Email")
press = input("Press Any Key To Continue..")
Update_Employ()
Phone_no = input("Enter Employee Phone No.: ")
18
if(Pattern.match(Phone_no)):
print("Valid Phone Number")
else:
print("Invalid Phone Number")
press = input("Press Any Key To Continue..")
Update_Employ()
Address = input("Enter Employee Address: ")
# Updating Employee details in empdata Table
sql = 'UPDATE empdata set Email_Id = %s, Phone_no = %s, Address = %s
where Id = %s'
data = (Email_Id, Phone_no, Address, Id)
c = con.cursor()
# Executing the sql query
c.execute(sql, data)
# commit() method to make changes in the table
con.commit()
print("Updated Employee Record")
19
press = input("Press Any Key To Continue..")
menu()
# Function to Promote_Employ
def Promote_Employ():
print("{:>60}".format("-->> Promote Employee Record <<--\n"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if(check_employee(Id) == False):
print("Employee Record Not exists\nTry Again")
press = input("Press Any Key To Continue..")
menu()
else:
Amount = int(input("Enter Increase Salary: "))
#query to fetch salary of Employee with given data
sql = 'select Salary from empdata where Id=%s'
data = (Id,)
20
c = con.cursor()
21
press = input("Press Any key To Continue..")
menu()
# Function to
Remove_Employee def
Remove_Employ():
print("{:>60}".format("-->> Remove Employee Record <<--\n"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if(check_employee(Id) == False):
print("Employee Record Not exists\nTry Again")
press = input("Press Any Key To Continue..")
menu()
else:
#query to delete Employee from empdata table
sql = 'delete from empdata where Id = %s'
data = (Id,)
c = con.cursor()
22
#executing the sql query
23
c.execute(sql, data)
#commit() method to make changes in the empdata table
con.commit()
print("Employee Removed")
press = input("Press Any key To Continue..")
menu()
# Function to Search_Employ
def Search_Employ():
print("{:>60}".format("-->> Search Employee Record <<--\n"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if(check_employee(Id) == False):
print("Employee Record Not exists\nTry Again")
press = input("Press Any Key To Continue..")
menu()
else:
#query to search Employee from empdata table
24
sql = 'select * from empdata where Id = %s'
data = (Id,)
c = con.cursor()
25
press = input("Press Any key To Continue..")
menu()
# Menu function to display menu
def menu():
os.system("cls")
print("{:>60}".format("************************************"))
print("{:>60}".format("-->> Employee Management System <<--"))
print("{:>60}".format("************************************"))
file = open('help.txt','w')
27
if ch == 1:
os.system("cls")
Add_Employ()
elif ch == 2:
os.system("cls")
Display_Employ()
elif ch == 3:
os.system("cls")
Update_Employ()
elif ch == 4:
os.system("cls")
Promote_Employ()
elif ch == 5:
os.system("cls")
Remove_Employ()
elif ch == 6:
os.system("cls")
28
Search_Employ()
elif ch == 7:
os.system("cls")
print("{:>60}7".format("Have A NIce Day :)"))
exit(0)
elif ch == 8:
file = open('help.txt','r')
help_file = file.read()
print(help_file)
else:
print("Invalid Choice!")
press = input("Press Any key To Continue..")
menu()
# Calling menu function
menu()
29
OUTPUT
30
31
32
33
Bibliography
34