This project is a command-line application that allows users to manage employee records using an SQLite database. The system provides functionalities to add, view, access, update, and delete employee records stored in the database details.db
.
- Python 3.x
- SQLite3 library (built into Python)
-
Inserting Employee Records
- Adds a new employee record to the database.
- Requires the user to provide:
- Employee ID
- Name
- Designation
- Salary
-
Viewing All Employee Records
- Displays all employee records stored in the database.
- If no records are found, prompts the user to add new records.
-
Accessing a Particular Record
- Retrieves and displays the details of an employee by their ID.
- Shows the ID, Name, Designation, and Salary if found.
-
Updating an Employee Record
- Updates specific fields (Name, Designation, or Salary) of an employee based on their ID.
- Validates if the record exists before making changes.
-
Deleting an Employee Record
- Deletes a specific employee record by ID.
- Prompts for confirmation before performing the deletion.
-
Exiting the Application
- Terminates the program gracefully.
The employee
table schema:
CREATE TABLE employee(
ID INTEGER PRIMARY KEY,
NAME TEXT NOT NULL,
DESIGNATION TEXT NOT NULL,
SALARY INTEGER
);
- Save the code to a Python file (e.g.,
employee_management.py
). - Open a terminal or command prompt.
- Run the program:
python employee_management.py
- Follow the on-screen menu to perform operations.
When running the program, you will see the following menu:
***********LIST OF THE OPERATIONS ************
1. INSERTING AN employee RECORD INTO DATABASE
2. VIEWING THE LIST OF employee RECORDS IN THE DATABASE
3. ACCESSING A PARTICULAR RECORD FROM THE DATABASE
4. UPDATE A PARTICULAR RECORD IN DATABASE
5. DELETING A PARTICULAR RECORD IN DATABASE
6. EXIT
Enter the number corresponding to the operation you want to perform.
-
Insert a Record:
- Select option
1
and provide the required employee details.
- Select option
-
View All Records:
- Select option
2
to see all employee records.
- Select option
-
Access a Record:
- Select option
3
and enter the employee ID.
- Select option
-
Update a Record:
- Select option
4
, specify the employee ID, and choose the field to update.
- Select option
-
Delete a Record:
- Select option
5
, specify the employee ID, and confirm deletion.
- Select option
-
Exit:
- Select option
6
to exit the application.
- Select option
- Validates user input to ensure correct data types (e.g., integers for IDs and salaries).
- Checks for the existence of records before performing operations like update or delete.
- Displays appropriate messages for invalid or non-existent IDs.
- Ensure the
details.db
file is created in the working directory before running the program. - Back up the database file if needed, as deleting records is irreversible.
- The database operations are committed immediately to maintain data integrity.
This project is open-source and available for educational purposes.