S.NO CONTENT PAGE.
NO
1 About the project
2 Features of python
3 Features of MYSQL
4 Module Description
5 Coding
6 Output
7 Requirement
8 Bibliography
PYTHON FEATURES
Python provides many useful features which make it popular and valuable from
the other programming supports object-oriented programming, procedural
programming approaches and provides dynamic memory allocation. We have
listed below a few essential features.
1) Easy to Learn and Use
Python is easy to learn as compared to other programming languages. Its syntax is
straightforward and much the same as the English language. There is no use of the
semicolon or curly-bracket, the indentation defines the code block. It is the
recommended programming language for beginners.
2) Expressive Language
Python can perform complex tasks using a few lines of code. A simple example, the
hello world program you simply type print ("Hello World"). It will take only one line
to execute, while Java or C takes multiple lines.
3) Interpreted Language
Python is an interpreted language; it means the Python program is executed one line
at a time. The advantage of being interpreted language, it makes debugging easy and
portable
4) Cross-platform Language
Python can run equally on different platforms such as Windows, Linux, UNIX, and
Macintosh, etc. So, we can say that Python is a portable language. It enables
programmers to develop the software for several competing platforms by writing a
program only once.
5) Free and Open Source
Python is freely available for everyone. It is freely available on its official website
It has a large community across the world that is dedicatedly working towards make
new python modules and functions. Anyone can contribute to the Python community.
The open-source means, "Anyone can download its source code without paying any
penny."
6) Object-Oriented Language
Python supports object-oriented language and concepts of classes and objects come
into existence. It supports inheritance, polymorphism, and encapsulation, etc. The
object-oriented procedure helps to programmer to write reusable code and develop
applications in less code.
7) Extensible
It implies that other languages such as C/C++ can be used to compile the code and
thus it can be used further in our Python code. It converts the program into byte code,
and any platform can use that byte code.
8) Large Standard Library
It provides a vast range of libraries for the various fields such as machine learning,
web developer, and also for the scripting. There are various machine learning
libraries, such as Tensor flow, Pandas, Numpy, Keras, and Pytorch, etc. Django,
flask, pyramids are the popular framework for Python web development.
9) GUI Programming Support
Graphical User Interface is used for the developing Desktop application. PyQT5,
Tkinter, Kivy are the libraries which are used for developing the web application.
10) Integrated
It can be easily integrated with languages like C, C++, and JAVA, etc. Python runs
code line by line like C, C++ Java. It makes easy to debug the code.
11. Embeddable
The code of the other programming language can use in the Python source code.
We can use Python source code in another programming language as well. It can
embed other language into our code.
12. Dynamic Memory Allocation
In Python, we don't need to specify the data-type of the variable. When we assign
some value to the variable, it automatically allocates the memory to the variable at
run time.
MySQL Features
MySQL is a relational database management system (RDBMS) based on the SQL
(Structured Query Language) queries. It is one of the most popular languages for
accessing and managing the records in the table. MySQL is open-source and free
software under the GNU license. Oracle Company supports it.
The following are the most important features of MySQL:
Relational Database Management System (RDBMS)
MySQL is a relational database management system.
This database language is based on the SQL
Queries to access and manage the records of the table.
Easy to use
MySQL is easy to use. We have to get only the basic knowledge of SQL. We can build
and interact with MySQL by using only a few simple SQL statements.
It is secure
MySQL consists of a solid data security layer that protects sensitive data from
intruders. Also, passwords are encrypted in MySQL.
Client/ Server Architecture
MySQL follows the working of a client / server architecture. There is a database
server (MySQL) and arbitrarily many clients (application
Programs), which communicate with the server: that is, they can query data, save
changes, etc.
Free to download
MySQL is free to use so that we can download it from MySQL official website
without any cost.
It is scalable
MySQL supports multi-threading that makes it easily scalable. It can handle almost
any amount of data, up to as much as 50 million rows or more. The default file size
limit is about 4 GB. However, we can increase this number to a theoretical limit of 8
TB of data.
Speed
MySQL is considered one of the very fast database languages, backed by a large
number of the benchmark test.
High Fexibility
MySQL supports a large number of embedded applications, which makes MySQL
very flexible.
Compatible on many operating systems
MySQL is compatible to run on many operating systems, like Novell Netware,
Windows Linux, many varieties of UNIX (such as Sun Solaris*, AIX, and DEC UNIX),
OS/2, FreeBSD*, and others. MySQL also provides a facility that the clients can run
on the same computer as the server or on another computer (communication via a
local network or the Internet).
Allows roll-back
MySQL allows transactions to be rolled back, commit, and crash recovery.
Memory efficiency
Its efficiency is high because it has a very low memory leakage problem.
High Performance
MySQL is faster, more reliable, and cheaper because of its unique storage engine
architecture. It provides very high-performance results in comparison to other
databases without losing an essential functionality of the software. It has fast
loading utilities because of the different cache memory.
High Productivity
MySQL uses Triggers, Stored procedures, and views that allow the developer to give
higher productivity.
Platform Independent
It can download, install, and execute on most of the available operating systems.
Partitioning
This feature improves the performance and provides fast management of the large
database.
GUI Support
MySQL provides a unified visual database graphical user interface tool named
"MySQL Workbench" to work with database architects, developers, and Database
Administrators.
Provides SQL development, data modeling , data migration, and comprehensive
administration tools for server configuration, user administration, backup, and
many more. MySQL has a fully GUI supports from MySQL Server version 5.6 and
higher.
Dual Password Support
MySQL version 8.0 provides support for dual passwords: one is the current
password, and another is a secondary password, which allows us to transition to the
new password.
Disadvantages/Drawback of MySQL
Following are the few disadvantages of MySQL:
• MySQL version less than 5.0 doesn't support ROLE, COMMIT, and stored
procedure.
• MySQL does not support a very large database size as efficiently.
• MySQL doesn't handle transactions very efficiently, and it is prone to data
corruption.
• MySQL is accused that it doesn't have a good developing and debugging tool
compared to paid databases.
MODULE DESCRIPTION
import MySQL. Connector
MySQL is a Relational Database Management System (RDBMS) whereas the
structured Query Language (SQL) is the language used for handling the RDBMS
using commands
i.e Creating, Inserting, Updating and Deleting the data from the databases. SQL
commands are case insensitive i.e CREATE and create signify the same command.
In this article, we will be discussing the MySQL Connector module of Python, how
to install this module and a piece of code on how to connect this with the MySQL
database. For any application, it is very important to store the database on a
server for easy data access.
CODING
SOURE CODE
#PROJECT EMPLOYEE MANAGEMENT SYSTEM
# importing mysql connector
import mysql.connector
# making Connection
con = mysql.connector.connect(
host="localhost", user="root", password="password", database="emp")
# Function to mAdd_Employee
def Add_Employ():
Id = input("Enter Employee Id : ")
# Checking if Employee with given Id
# Already Exist or Not
if(check_employee(Id) == True):
print("Employee aready exists\nTry Again\n")
menu()
else:
Name = input("Enter Employee Name : ")
Post = input("Enter Employee Post : ")
Salary = input("Enter Employee Salary : ")
data = (Id, Name, Post, Salary)
# Inserting Employee details in
# the Employee Table
sql = 'insert into empd values(%s,%s,%s,%s)'
c = con.cursor()
# Executing the SQL Query
c.execute(sql, data)
# commit() method to make changes in
# the table
con.commit()
print("Employee Added Successfully ")
menu()
# Function to Promote Employee
def Promote_Employee():
Id = int(input("Enter Employ's Id"))
# Checking if Employee with given Id
# Exist or Not
if(check_employee(Id) == False):
print("Employee does not exists\nTry Again\n")
menu()
else:
Amount = int(input("Enter increase in Salary"))
# Query to Fetch Salary of Employee
# with given Id
sql = 'select salary from empd where id=%s'
data = (Id,)
c = con.cursor()
# Executing the SQL Query
c.execute(sql, data)
# Fetching Salary of Employee with given Id
r = c.fetchone()
t = r[0]+Amount
# Query to Update Salary of Employee with
# given Id
sql = 'update empd set salary=%s where id=%s'
d = (t, Id)
# Executing the SQL Query
c.execute(sql, d)
# commit() method to make changes in the table
con.commit()
print("Employee Promoted")
menu()
# Function to Remove Employee with given Id
def Remove_Employ():
Id = input("Enter Employee Id : ")
# Checking if Employee with given Id Exist
# or Not
if(check_employee(Id) == False):
print("Employee does not exists\nTry Again\n")
menu()
else:
# Query to Delete Employee from Table
sql = 'delete from empd where id=%s'
data = (Id,)
c = con.cursor()
# Executing the SQL Query
c.execute(sql, data)
# commit() method to make changes in
# the table
con.commit()
print("Employee Removed")
menu()
# Function To Check if Employee with
# given Id Exist or Not
def check_employee(employee_id):
# Query to select all Rows f
# rom employee Table
sql = 'select * from empd where id=%s'
# making cursor buffered to make
# rowcount method work properly
c = con.cursor(buffered=True)
data = (employee_id,)
# Executing the SQL Query
c.execute(sql, data)
# rowcount method to find
# number of rows with given values
r = c.rowcount
if r == 1:
return True
else:
return False
# Function to Display All Employees
# from Employee Table
def Display_Employees():
# query to select all rows from
# Employee Table
sql = 'select * from empd'
c = con.cursor()
# Executing the SQL Query
c.execute(sql)
# Fetching all details of all the
# Employees
r = c.fetchall()
for i in r:
print("Employee Id : ", i[0])
print("Employee Name : ", i[1])
print("Employee Post : ", i[2])
print("Employee Salary : ", i[3])
print(‘’’---------------------\
-----------------------------\
------------------------------\
---------------------‘’’)
menu()
# menu function to display menu
def menu():
print("Welcome to Employee Management Record")
print("Press ")
print("1 to Add Employee")
print("2 to Remove Employee ")
print("3 to Promote Employee")
print("4 to Display Employees")
print("5 to Exit")
ch = int(input("Enter your Choice "))
if ch == 1:
Add_Employ()
elif ch == 2:
Remove_Employ()
elif ch == 3:
Promote_Employee()
elif ch == 4:
Display_Employees()
elif ch == 5:
exit(0)
else:
print("Invalid Choice")
menu()
# Calling menu function
menu()
OUTPUT
OUTPUT:
REQUIREMENT
HARDWARE
Display : Monitor
Processor : Dual core, AMD Athlon & above
Hard disk : 80 GB & above
Ram : 1 GB & above
SOFTWARE
Operating system : Windows 7 & above
Application Software : Python IDLE
Database : MySQL 8.0
BIBLIOGRAPHY
• COMPUTER SCIENCE WITH PYTHON BY:- SUMITAARORA
• http/www.cbseportal.com
• http://cbse-sample-papers.blogspot.com
• www.w3source.com
• www.pythonworld.com