[go: up one dir, main page]

0% found this document useful (0 votes)
25 views15 pages

CS Project

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

CS Project

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

CONTENTS

1. ACKNOWLEDGEMENT

2. INTRODUCTION

3. SOFTWARE

4. WORKING ENVIRONMENT

▪ Existing System

▪ Drawbacks

▪ Proposed System

5. SCREEN & OUTPUT

6. SOURCE CODE

7. CONLUSION

8. BIBLIOGRAPHY
ACKNOWLEDGEMENT
This compilation project on “EMPLOYEE DATABASE” is a
mere result of hard work of an individual.

I am presenting this compilation with a deep and sincere


gratitude and respect to our respected Principal Mr. Benny T.
C and Computer Science teacher Mrs. Mangala Aneesh for
the encouragement, support and timely interventions and
supervisions without which I could not have completed my
compilation.

I am also thankful to out librarian who helped us by


providing various helpful reference materials and guidance.

I am also thankful to all the teaching and non-teaching staff


who helped directly and indirectly in this work.

I offer obligations to my friends, particularly for their

support during this work.


INTRODUCTION
Office record is regarded as an essential part of any

company’s working. Maintaining the details of employees is

a must in all offices. This database helps a company to

identify, manage and supervise employee details.

This office database gives detailed information about the

employees. It’s easy to manage this database using the

simple and easy-to-understand user interface.


SOFTWARE

PLATFORM: Microsoft Windows 11

FRONTEND: Python 3.9 (64 bit)

BACKEND: MySQL 8.0


WORKING ENVIRONMENT
Proposed System:
➢ This is a user-friendly application/program.
➢ Only basic computer knowledge is required for
operation.
➢ The program is customisable/user-configurable
according to needs.
➢ System requirements are less and can be run on even
low-end devices.
➢ It helps to keep record of employees safe and secure.
➢ The records are well-managed.
➢ It makes it easier to find the necessary data.

Drawbacks:
Employee record system has a user-friendly application
interface. But it cannot be operated by mouse as it is a
command line-based program.
SOURCE CODE
import mysql.connector as mycon
import os #The module’s function is used at the end for pausing
the system for some time after the output displays

con = mycon.connect(host="localhost", user="root",


password="asdf123*") #Password may vary with the system

print(con)
cur = con.cursor()
cur.execute("CREATE DATABASE IF NOT EXISTS office")
cur.execute("USE office")
cur.execute("CREATE TABLE IF NOT EXISTS employee(employeeno
integer(4), name varchar(25), age int(4), address varchar(30), dept
varchar(20), salary int(10))")
user = 'y'
print("\n########### WELCOME TO OFFICE DATABASE MANAGEMENT SYSTEM
############\n\n")

while user == 'y':


print("""1: Add record
2: Update record
3: Delete record
4: Display table
0: Exit\n""")
choice = int(input("Enter your choice from the above menu: "))
if choice == 1:
add_more = 'y'
while add_more == 'y':
employeeno = int(input("\nEnter employee no.: "))
name = input("Enter employee name: ")
age = int(input("Enter age: "))
address = input("Enter address: ")
dept = input("Enter department: ")
salary = int(input("Enter salary: "))
query = "INSERT INTO employee VALUES({}, '{}', {}, '{}',
'{}', {})".format(employeeno, name, age, address, dept, salary)
cur.execute(query)
con.commit()
print("\n## DATA SAVED SUCCESSFULLY ##")
add_more = input("\nDo you want to add more data? (y/n):
")
user = input("\nDo you want to continue? (y/n): ")
elif choice == 2:
employee_no_for_updation = int(input("\nEnter employee no.
of the employee whose details are to be updated: "))
s = 'y'
while s == 'y':
update_detail = int(input("""What do you want to update?
1: Name
2: Age
3: Address
4: Department
5: Salary

Enter your choice: """))


if update_detail == 1:
new_name = input("Enter new name: ")
sql = "UPDATE employee SET name=%s WHERE
employeeno=%s"
input_data = (new_name, employee_no_for_updation)
cur.execute(sql, input_data)
con.commit()
s = input("\nDo you want to update more data? (y/n):
")
elif update_detail == 2:
new_age = int(input("Enter new age: "))
sql = "UPDATE employee SET age=%s WHERE
employeeno=%s"
input_data = (new_age, employee_no_for_updation)
cur.execute(sql, input_data)
con.commit()
s = input("\nDo you want to update more data? (y/n):
")
elif update_detail == 3:
new_address = input("Enter new address: ")
sql = "UPDATE employee SET address=%s WHERE
employeeno=%s"
input_data = (new_address, employee_no_for_updation)
cur.execute(sql, input_data)
con.commit()
s = input("\nDp you want to update more data? (y/n):
")
elif update_detail == 4:
new_dept = input("Enter new department: ")
sql = "UPDATE employee SET dept=%s WHERE
employeeno=%s"
input_data = (new_dept, employee_no_for_updation)
cur.execute(sql, input_data)
con.commit()
s = input("\nDo you want to update more data? (y/n):
")
elif update_detail == 5:
new_salary = int(input("Enter new salary: "))
sql = "UPDATE employee SET salary=%s WHERE
employeeno=%s"
input_data = (new_salary, employee_no_for_updation)
cur.execute(sql, input_data)
con.commit()
s = input("\nDo you want to update more data? (y/n):
")
print(cur.rowcount, "record(s) affected.")
user = input("\nDo you want to continue? (y/n): ")
elif choice == 3:
num = int(input("Enter employee no. of employee to be
deleted from the record: "))
sql = "DELETE FROM employee WHERE employeeno=%s"
num1 = (num,)
cur.execute(sql, num1)
con.commit()
print(cur.rowcount, "record(s) deleted.")
user = input("\nDo you want to continue? (y/n): ")
elif choice == 4:
cur.execute("SELECT * FROM employee")
myresult = cur.fetchall()
for x in myresult:
print(x)
user = input("\nDo you want to continue? (y/n): ")
elif choice == 0:
print("\nThank you for using OFFICE DATABASE MANAGEMENT
SYSTEM!")
user = "exit"
else:
print("\nLooks like you have selected an invalid choice. Try
again.")
user = input("\nDo you want to continue? (y/n): ")
os.system("pause")
SCREEN & INPUT
Menu-driven Execution:
Option 1: Add record

After adding employee details, the data in the SQL database that is
connected with the program changes.
The table will be as follows:
Option 2: Update record
Option 3: Delete record

The SQL database connected with the program is updated when the
employee details are updated in the program.

The table will be as follows:

Option 4: Display table


Option 5: Exit

The program closes only after pressing any key because of the
function system(“pause”) from the module os . This code is used
here for pausing the system for a while after the output has been
displayed. A command prompt window opens up asking to press any
key.

This step is completely optional, and can be avoided.

Note: If an incorrect choice is given for the menu, an error message


is displayed as given below:
CONCLUSION

The project was successfully accomplished and we tried our


level best to turn it into a user-friendly platform. This is a
computer-based system which supports addition of
employee data such as employee name, age, address,
department and salary, and keep it secure and well
preserved.
BIBLIOGRAPHY

Websites:
▪ www.python.org
▪ www.stackoverflow.com
▪ www.mysql.com
▪ www.tutorialspoint.com
▪ www.javapoint.com
▪ www.geeksforgeeks.com
▪ www.w3schools.com
▪ www.wikipedia.com

Books:
▪ Computer Science with Python (Class XII) – By Preeti
Aurora

Other:
▪ Friends

You might also like