J.B. Memorial Manas Academy Pithoragarh: Practical File OF Computer Science
J.B. Memorial Manas Academy Pithoragarh: Practical File OF Computer Science
MEMORIAL MANAS
ACADEMY
PITHORAGARH
PRACTICAL FILE
OF
COMPUTER SCIENCE
Submitted by Submitted to
Kastura bhat Mr. Devendra
XII ‘A’ Mahori
1|Page
CONTENTS
2|Page
J.B. Memorial Manas Academy
Pithoragarh
CERTIfICATE
DEVENDRA Mahori
3|Page
ACkNOwLEDGMENT
I am immensely grateful to my project guide Mr. Devendra Mahori,
for their invaluable guidance and unwavering support throughout the
duration of this project. Their expertise and mentorship have been
instrumental in shaping the project’s direction and ensuring its
successful completion. I would also like to extend my heartfelt
appreciation to my classmates who collaborated with me on this
project. Their contributions and collective effort have greatly enriched
the outcome.
4|Page
PROJECT
ANALYSIS
This project is designed to manage and add employees data.It
includes a basic set of all the function required in the any
organisation which are used to reduce the time and increases
the efficiency. It includes-
5|Page
About
python
Python is a high-level, interpreted programming language that
emphasizes readability and simplicity. Developed by Guido
van Rossum and first released in 1991, Python has become one
of the most popular and versatile programming languages.
Some key features include:
6|Page
About MySQL
MySQL is a widely-used open-source relational database
management system (RDBMS). Developed by Oracle
Corporation, it's known for its reliability, performance, and
ease of use. Key features include:
• Relational Database: MySQL follows a relational database
model, organizing data into tables with predefined relationships.
• Open Source: As an open-source RDBMS, MySQL is freely
available, fostering widespread adoption and community
collaboration.
• Cross-Platform Compatibility: MySQL is compatible with
various operating systems, ensuring versatility across different
environments.
• SQL Language Support: It supports the Structured Query
Language (SQL), providing a standardized means to interact with
databases.
• Scalability: MySQL caters to both small-scale applications and
7|Page
Introduction
The software is used to maintain the records of all
employees, adding new employee data and to search for
a employee.
Objective
The objective of this project is to let students apply the
programming knowledge to the real-world situation and
exposed the students how programming skills helps in
developing a good software.
8|Page
CONNECTING
PYTHON TO SqL
import mysql.connector
# Replace these values with your MySQL server details
host = '127.0.0.1' user = 'root' password = 'Sql@369'
database = 'employee' port = 3306 try:
# Connect to the MySQL database
conn = mysql.connector.connect(
host=host, user=user,
password=password,
database=database, port=port
)
# Check if the connection was successful
if conn.is_connected():
print("Connection to MySQL database established
successfully!") except mysql.connector.Error as err:
print(f"Error: {err}") finally:
# Close the connection if 'conn' in
locals() and conn.is_connected():
conn.close()
print("MySQL connection closed.")
Output:
9|Page
10 | P a g e
SOuRCE CODE
Import mysql.connector
Def establish_connection():
Host = ‘127.0.0.1’
User = ‘root’
Password = ‘Sql@369’
Database = ‘employee’
Try:
Connection = mysql.connector.connect(
Host=host,
User=user,
Password=password,
Database=database
Return connection
Print(f”Error: {err}”)
Return None
11 | P a g e
Def create_employee_table(connection):
Try:
Cursor = connection.cursor()
Cursor.execute(“””
Name VARCHAR(255),
Position VARCHAR(255),
Salary DECIMAL(10, 2)
“””)
Connection.commit()
Print(f”Error: {err}”)
Try:
Cursor = connection.cursor()
Cursor.execute(“””
12 | P a g e
VALUES (%s, %s, %s)
Connection.commit()
Print(f”Error: {err}”)
Def view_employees(connection):
Try:
Cursor = connection.cursor()
Employees = cursor.fetchall()
If not employees:
Else:
Print(f”Error: {err}”)
13 | P a g e
Def search_employee(connection, employee_id):
Try:
Cursor = connection.cursor()
Employee = cursor.fetchone()
If not employee:
Else:
Print(f”Error: {err}”)
If name == “ main ”:
# Establishing a connection
Connection = establish_connection()
If connection:
Create_employee_table(connection)
14 | P a g e
While True:
Print(“4. Exit”)
If choice == ‘1’:
View_employees(connection)
Search_employee(connection, employee_id)
15 | P a g e
Elif choice == ‘4’:
Break
Else:
If connection.is_connected():
Connection.close()
Print(“Connection closed”)
OuTPuT wINDOw
16 | P a g e
17 | P a g e
ADDING Employee Data
18 | P a g e
SEARCHING A EMPLOYEE
19 | P a g e
fuTuRE SCOPE Of PROJECT
BIBLIOGRAPHY