This project is made using two parts.
First : coding for making tables in mysql server.
Second : coding for using project interface.
Software Requirements
Mysql server : mysql server must be installed in computer. It will be used for accessing data of project. Tables will be made in server in which data will be stored.
Python idle : python idle must be installed in computer. It will be used for executing python scripts.
Mysql.connector : it will connect python idle with mysql server. To install it open cmd and write pip install mysql.connector
MySQL
import mysql.connector as a
con = a.connect(host="localhost",
user="root",
passwd="1234")
c = con.cursor()
sql1 = "create database employee"
c.execute(sql1)
sql2 = "use employee"
c.execute(sql2)
sql3 = "create table personal (name varchar(50),city varchar(20), dob varchar(20), phone varchar(20))"
c.execute(sql3)
sql4 = "create table office (ecode varchar(10),name varchar(50), post varchar(20), jdate varchar(20),basicpay int)"
c.execute(sql4)
sql5 = "create table salary (ecode varchar(10), name varchar(50), year varchar(10), month varchar(20), wdays int, tdays int)"
c.execute(sql5)
con.commit()
Python
import mysql.connector as a
con = a.connect(host="localhost",
user="root",
passwd="",
database="employee")
def npersonal():
n = input("Enter Employee Name : ")
c = input("Enter Employee's City Name : ")
d = input("Enter Employee's D.O.B : ")
p = input("Enter Employee Phone : ")
data = (n,c,d,p)
sql = 'insert into personal values(%s,%s,%s,%s)'
c = con.cursor()
c.execute(sql,data)
con.commit()
print("Data Entered Successfully")
main()
def personal():
sql = "select * from personal"
c = con.cursor()
c.execute(sql)
d = c.fetchall()
for i in d:
print(i)
main()
def noffice():
ec = input("Enter Employee Code : ")
n = input("Enter Employee Name : ")
ps = input("Enter Employee's Post : ")
j = input("Enter Employee's joining date : ")
bp = int(input("Enter Assigned Salary : "))
data = (ec,n,ps,j,bp)
sql = 'insert into office values(%s,%s,%s,%s,%s)'
c = con.cursor()
c.execute(sql,data)
con.commit()
print("Data Entered Successfully")
main()
def office():
sql = "select * from office"
c = con.cursor()
c.execute(sql)
d = c.fetchall()
for i in d:
print(i)
main()
def nsalary():
ec = input("Enter Employee Code : ")
v = (ec,)
sql = "select BasicPay from office where Ecode = %s"
c = con.cursor( )
c.execute(sql,v)
bs = c.fetchone( ) # (30000,)
n = input("Enter Employee Name : ")
y = input("Enter Year : ")
m = input("Enter Month : ")
wd = int(input("Enter working Days : "))
td = int(input("Enter Total Days : "))
fp = bs[0]/td*wd
data = (ec,n,y,m,wd,fp)
sql = 'insert into salary values(%s,%s,%s,%s,%s,%s)'
c = con.cursor()
c.execute(sql,data)
con.commit()
print("Data Entered Successfully")
main()
def salary():
sql = "select * from salary"
c = con.cursor()
c.execute(sql)
d = c.fetchall()
for i in d:
print(i)
main()
def main():
print("""
1. Add New Employee Personal Details
2. Display Employees Personal Details
3. Add New Employee Office Details
4. Display Employees Office Details
5. Enter Salary Details of Employee
6. Display Salary Details of Employee""")
choice = input("Enter Task No : ")
while True:
if (choice == '1'):
npersonal()
elif (choice=='2'):
personal()
elif (choice=='3'):
noffice()
elif (choice=='4'):
office()
elif (choice=='5'):
nsalary()
elif (choice == '6'):
salary()
else:
print(" Wrong choice..........")
main()
Educational Use Notice
This project is provided strictly for educational and learning purposes. Students are encouraged to study the code, understand the concepts, and use it as a reference for building their own original projects. Users are expected to modify, improve, and create their own implementations based on their understanding. By accessing this project, you agree to use it ethically and in accordance with your institution’s academic integrity policies.
