Industrial Gate Management System Python Project

 

Explanation :  The aim of this project is to manage the visitors/resident record who has entered the industry campus. An industry that also has residential area in its campus has to manage the incoming/outgoing data of visitor either they are the employee, guests, tutor, milkman etc. The project  Industrial Gate Management System will fulfill industry needs. In this project we have proper entry system.  Option like employee details, visitor details, resident details, vehicle details etc can be managed using this project.Here we go with source code.

 

Source  Code:

Creating database for Industrial Gate Management System

import mysql.connector as sq
def database():
    mycon = sq.connect(host='localhost',user='root',password='admin')
    mycursor = mycon.cursor()
    mycursor.execute("CREATE DATABASE employee")
    #mycursor.execute("CREATE DATABASE employee_entry")
    mycursor.execute("CREATE DATABASE vechicle_entry")
    mycursor.execute("CREATE DATABASE visitor_entry")
    mycursor.execute("CREATE DATABASE residental_entry")
def emp():
    mycon = sq.connect(host='localhost',user='root',password='admin',database='employee')
    cur = mycon.cursor()
    cur.execute("CREATE TABLE employee(NAME varchar(30) not null,EMP_CODE int not null unique,TIME time not null,DEPARTMENT varchar(30))")
    mycon.commit()
def veh():
    mycon = sq.connect(host='localhost',user='root',password='admin',database='vechicle_entry')
    cur = mycon.cursor()
    cur.execute("CREATE TABLE vechicle_entry(VECHICLE_NUMBER int,DRIVER_NAME varchar(30) not null,TIME time not null,MATERIAL varchar(30))")
def vis():
    mycon = sq.connect(host='localhost',user='root',password='admin',database='visitor_entry')
    cur = mycon.cursor()
    cur.execute("CREATE TABLE visitor_entry(NAME varchar(30) not null,TIME time not null,MOBILE_NUMBER int unique,REASON varchar(90))")
def res():
    mycon = sq.connect(host='localhost',user='root',password='admin',database='residental_entry')
    cur = mycon.cursor()
    cur.execute("CREATE TABLE residental_entry(NAME varchar(30) not null,TIME time not null,HOUSE_NUMBER varchar(10) not null)")
database()
veh()
emp()
vis()
res()

 

 

 

Managing database :

import datetime
import mysql.connector as sq
def date_time():
    return datetime.datetime.now()
def sql_emp(N,C,T,D):
    data = sq.connect(host='localhost', user='root', password='admin', database='employee')
    cur = data.cursor()
    #if data.is_connected():
        #print('connected sucessfully')
    q = "INSERT INTO employee(NAME,EMP_CODE,TIME,DEPARTMENT) VALUES(%s,%s,%s,%s)"
    val = (N,C,T,D)
    cur.execute(q,val)
    data.commit()
    data.close()
def sql_update(Sr):
    data = sq.connect(host='localhost',user='root',password='admin',database='employee')
    cur = data.cursor()
    print('WHAT DO YOU WANT TO CHANGE \n PRESS 1 FOR NAME \n PRESS 2 FOR CODE \n PRESS 3 FOR DEAPRTMENT \n PRESS 4 FOR LAST ENTERED DATA TO CHANGE')
    i = int(input('enter number'))
    if i == 1:
        n = input('ENTER NAME')
        cur.execute(f"UPDATE employee SET NAME='{n}' WHERE NAME='{Sr}'")
        data.commit()
    elif i == 2:
        n1 = int(input("enter code"))
        cur.execute("UPDATE employee SET EMP_CODE={} WHERE NAME={}".format(n1,Sr))
        data.commit()
    elif i == 3:
        n2 = input("enter department")
        cur.execute("UPDATE employee SET DEPARTMENT='{}' WHERE NAME='{}'".format(n2,Sr))
        data.commit()
    elif i == 4:
        n3 = input("enter name")
        n4 = int(input("enter emp_code"))
        n5 = input("enter department")
        cur.execute("UPDATE employee SET NAME={},EMP_CODE={},DEPARTMENT={} WHERE NAME={}".format(n3,n4,n5,Sr))
        data.commit()
    data.close()
def sql_vechicle(VN,DN,T,M):
    data = sq.connect(host='localhost', user='root', password='admin', database='vechicle_entry')
    cur = data.cursor()
    q = "INSERT INTO vechicle_entry(VECHICLE_NUMBER,DRIVER_NAME,TIME,MATERIAL) VALUES(%s,%s,%s,%s)"
    val = (VN,DN,T,M)
    cur.execute(q,val)
    data.commit()
    data.close()
def sql_vehupdate(veh_Sr):
    data = sq.connect(host='localhost', user='root', password='admin', database='vechicle_entry')
    cur = data.cursor()
    print(
        'WHAT DO YOU WANT TO CHANGE \n PRESS 1 FOR VECHICLE NUMBER'
        ' \n PRESS 2 FOR DRIVER NAME \n PRESS 3 FOR MATERIAL \n PRESS 4 FOR LAST ENTERED DATA TO CHANGE')
    i = int(input('enter number'))
    if i == 1:
        n = input('ENTER VECHICLE NUMBER')
        cur.execute("UPDATE vechicle_entry SET VECHICLE_NUMBER={} WHERE VECHICLE_NUMBER={}".format(n,veh_Sr))
        data.commit()
    elif i == 2:
        n1 = int(input("ENTER DRIVER NAME"))
        cur.execute("UPDATE vechicle_entry SET DRIVER_NAME='{}' WHERE VECHICLE_NUMBER={}".format(n1,veh_Sr))
        data.commit()
    elif i == 3:
        n2 = input("enter material")
        cur.execute("UPDATE vechicle_entry SET MATERIAL='{}' WHERE VECHICLE_NUMBER={}".format(n2,veh_Sr))
        data.commit()
    elif i == 4:
        n3 = input("enter vechicle number")
        n4 = int(input("enter driver name"))
        n5 = input("enter material")
        cur.execute("UPDATE vechicle_entry SET VECHICLE_NUMBER={},DRIVER_NAME='{}',MATERIAL='{}' WHERE VECHICLE_NUMBER={}".format(n3, n4, n5,veh_Sr))
        data.commit()
    data.close()
def sql_visitor(N,T,MN,R):
    data = sq.connect(host='localhost', user='root', password='admin', database='visitor_entry')
    cur = data.cursor()
    q = "INSERT INTO visitor_entry(NAME,TIME,MOBILE_NUMBER,REASON) VALUES(%s,%s,%s,%s)"
    val = (N,T,MN,R)
    cur.execute(q,val)
    data.commit()
    data.close()
def sql_residental(N,T,H):
    data = sq.connect(host='localhost', user='root', password='admin', database='residental_entry')
    cur = data.cursor()
    q = "INSERT INTO residental_entry(NAME,TIME,HOUSE_NUMBER) VALUES(%s,%s,%s)"
    val = (N,T,H)
    cur.execute(q,val)
    data.commit()
    data.close()
def sql_residentalupdate(res_Sr):
    data = sq.connect(host='localhost', user='root', password='admin', database='residental_entry')
    cur = data.cursor()
    print(
        'WHAT DO YOU WANT TO CHANGE \n PRESS 1 FOR NAME'
        ' \n PRESS 2 FOR HOUSE NUMBER \n PRESS 3 FOR LAST ENTERED DATA TO CHANGE')
    i = int(input("enter number"))
    if i == 1:
        n = input('ENTER NAME')
        cur.execute("UPDATE residental_entry SET NAME='{}' WHERE NAME='{}'".format(n,res_Sr))
        data.commit()
    elif i == 2:
        n1 = eval(input("ENTER HOUSE NUMBER"))
        cur.execute("UPDATE residental_entry SET HOUSE_NUMBER={} WHERE NAME='{}'".format(n1, res_Sr))
        data.commit()
    elif i == 3:
        n3 = input("enter NAME")
        n4 = eval(input("enter HOUSE NUMBER"))
        cur.execute(
            "UPDATE residental_entry SET NAME={},HOUSE_NUMBER={} WHERE RESIDENTAL_SERIAL_no={}".format(
                n3,n4,res_Sr))
        data.commit()
    data.close()
def employee():
    data = sq.connect(host='localhost',user='root',password='admin',database='employee')
    cur = data.cursor()
    cur.execute('select * from employee_entry')
    dat = cur.fetchall()
    for i in dat:
        print(i)
    print(" IF YOU WANT TO CHANGE ANY DATA ENTER Y/y")
    rr = input('enter to change any data')
    if rr == 'Y' or rr == 'y':
        print('which employee data you want to change')
        rr = int(input('enter employee code of the employee'))
        change_emp(rr)
def change_emp(rr):
    data = sq.connect(host='localhost', user='root', password='admin', database='employee')
    cur = data.cursor()
    n1 = input('enter name of employee::')
    n3 = input('enter department::')
    n4 = int(input('enter employee code'))
    cur.execute(f'UPDATE employee_entry set NAME = "{n1}",EMP_CODE = {n4},DEPARTMENT = "{n3}" WHERE EMP_CODE = {rr}')
    data.commit()
    i = True
    while i:
        print('want to change more data entry')
        print('or want to delete the data')
        print('press Y/y to change or D/d to delete the data')
        t = input('enter::')
        if t == 'Y' or t == 'y':
            na = input('enter name::')
            change_emp(na)
        elif t == 'D' or t == 'd':
            n4 = int(input('enter emp code whose data you want to delete'))
            cur.execute(f"delete from employee_entry where EMP_CODE = {n4}")
        else:
            i = False
def vechicle():
    data = sq.connect(host='localhost',user='root',password='admin',database='vechicle_entry')
    cur = data.cursor()
    cur.execute('select * from vechicle_entry')
    dat = cur.fetchall()
    print('\n')
    for i in dat:
        print(i)
def residental():
    data = sq.connect(host='localhost',user='root',password='admin',database='residental_entry')
    cur = data.cursor()
    cur.execute('select * from residental_entry')
    dat = cur.fetchall()
    for i in dat:
        print(i)
def visitor():
    data = sq.connect(host='localhost',user='root',password='admin',database='visitor_entry')
    cur = data.cursor()
    cur.execute('select * from visitor_entry')
    dat = cur.fetchall()
    for i in dat:
        print(i)


print("|===========================INDUSTRIAL GATE MANGEMENT SYSTEM============================|")
print('press one "1" or enter Y to enter data in the system::')
print('press one "2" or enter R to retrieve data from the system::')
i = input('enter 1/2 or Y/R::')
# CODE TO ENTER THE DATA INTO THE DATABASE
if (i == '1' or i == 'Y' or i=='y'):
    print("ENTER [EMP] OR 1 FOR EMPLOYEE ENTRY")
    print("ENTER [VEC] OR 2 FOR VECHICLE ENTRY")
    print("ENTER [RES] OR 3 FOR RESIDENTAL ENTRY")
    print("ENTER [VIS] OR 4 FOR VISITOR ENTRY")
    i1 = input('enter your choice press 1,2,3,4=')
    if (i1 == '1' or i1 == 'EMP'):
        k = True
        while k:
            n = input('enter name of employee')
            c = int(input('enter employee code of the employee'))
            t = date_time()
            d = input('enter department of the emplyee')
            sql_emp(n,c,t,d)
            print(f"DATA SUCCESSFULLY ENTERED OF EMPLOYEE NUMBER:\n EMPLOYEE NAME{n}")
            print("IF YOU WANT TO CHANGE LAST ENTERED DATA PRESS Y/y else N/n=")
            i2 = input('enter Y/y')
            if i2 == 'y' or i2 == 'Y':
                sql_update(n)
            print('WANT TO ENTER EMPLOYEE DATA AGAIN PRESS Y/y')
            K1 = input('enter y/Y else press any key')
            if K1 == 'Y' or K1 == 'y':
                k = True
            else:
                k = False
        else:
            pass
    elif (i1 == '2' or i1 == 'VEH'):
        vn = int(input('enter vechicle number'))
        dn = input("enter driver name")
        vt = date_time()
        ma = input("enter material name")
        sql_vechicle(vn,dn,vt,ma)
        print(f"DATA SICCESSFULLY ENTERED OF VECHICLE SERIAL NUMBER:\n vechicle number {vn}")
        print("IF YOU WANT TO CHANGE LAST ENTERED DATA PRESS Y/y")
        i3 = input('enter Y/y')
        if i3 == 'Y' or i3 == 'y':
            sql_vehupdate(vn)
    elif (i1 == '3' or i1 == 'RES'):
        rn = input("enter name of the person::")
        rt = date_time()
        hn = input("enter house number::")
        sql_residental(rn,rt,hn)
        print(f"DATA SUCCESSFULLY ENTERED OF REDANTIAL SERIAL NUMBER:\n NAME: {rn}")
        print("IF YOU WANT TO CHANGE LAST ENTERED DATA PRESS Y/y")
        i4 = input('enter Y/y')
        if (i4 == 'Y' or i4 == 'y'):
            sql_residentalupdate(rn)
    elif (i1 == '4' or i1 == 'VIS'):
        vn = input('enter name of visitor::')
        vt = date_time()
        vm = int(input('enter mobile number of the visitor::'))
        vr = input('enter reason to visit the area::')
        sql_visitor(vn,vt,vm,vr)
        print(f"DATA SUCCESSFULLY ENTERED OF VISITOR SERIAL NUMBER:\n NAME:{vn}")
# CODE TO READ THE ENTERED DATA
elif (i == '2' or i == 'R' or i == 'r'):
    print('SPECIFY WHICH DATABSE YOU WNAT TO ACCESS')
    print('    ')
    print("ENTER 1 TO RETRIEVE EMPLOYEE DATA")
    print("ENTER 2 TO RETRIEVE VECHICLE DATA")
    print("ENTER 3 TO RETRIEVE VISITOR DATA")
    print("ENTER 4 TO RETRIEVE RESIDENTAL DATA")
    r1 = input('enter number')
    if r1 == '1':
        employee()
    elif r1 == '2':
        vechicle()
    elif r1 == '3':
        visitor()
    elif r1 == '4':
        residental()

 

 

 

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved
error: Content is protected !!