Csproject
Csproject
Csproject
Computer Science
Shivam Sharma
Class: XII-F
Admission no:23135173
Certificate
This Project is a bona fide work of
Shivam Sharma of Class XII – F of
session 2024-25. Performed under
guidance of Mrs. Puja Gupta (PGT:
Computer Science, Mount Carmel
School, Dwarka).
Teacher’s Signature
_______________________
Acknowledgement
We thank our Computer Science
teacher, Mrs. Puja Gupta for her
invaluable guidance and the knowledge
she imparted through the year. We
would also like to thank our parents
who helped us a lot in finalizing this
file within a limited time frame. We
also extend my heartfelt gratitude to
the creators/authors of the various
sources we utilized to obtain relevant
information for this file.
Index
Mind map
Project Description
MySQL
Database structure
Modules used
Methods created
Utility methods
Preparing Database
Inserting records
Modifying records
Searching records
Display records
Deleting records
Main menu
Mind Map
Main Prepari
Deleting Menu ng
Records
Databse
Students
Marks Insertin
Display Managem
Records g
ent Records
System
Searchi Modifyin
ng g
Records Records
Project Description
Topic: MySQL Connectivity in Python
MYSQLs
MySQL is an open-source relational
database management system. Its
name is a combination of "My" (the
name of co-founder Michael Widenius's
daughter) and "SQL", the acronym for
Structured Query Language. It is a
widely used relational database
management system (RDBMS)which is
free and open-source. Itis idle for all
work uses from small applications to
big corporate organizations.
Database Structure
Database Name: csprac
Table Name: stu_records
Table Structure
Rollno: Roll number of the
student(integer)
Class: Grade and section of the
student (varchar(10))
Name:Name of the student
(varchar(50))
DOB: Date of birth of the student
(date)
Marks: Marks scored by the student
(int)
Modules Used
MySQL.connector module
Python module to connect to MySQL
server by using credentials and use
SQL commands through python into
the database. Here, we use the alias
“mc” to prevent repeating the long
module name. It provides a “connect”
function which takes in credentials
such as user, password, host and an
optional argument of database. The
connection object also has the commit
function which saves the data after
using a DML command
mc.connect(credentials)
con.commit()
The connection object provides a
‘cursor’ via which we can run SQL
commands.
con.cursor()
The cursor object provides a function
‘execute’ in which we write the SQL
statements we want to run.
cursor.execute()
datetime module:
Python datetime module supplies
classes for manipulating dates and
times. In this project it is used to
validate user input dates.
Methods created
1)Utility Methods
1)Check_valid_date
2)Preparing database
1)create DB
2)create TB
3)Insert
4)Modify
5)Search by roll number
6)Display methods:
1)Display all
2)Display above 90
3)Display below 33
7)Delete
8)Menu
Utility Methods
Check_valid_date:
Helps to validate whether the date
is in correct form of yyyy-mm-dd
Preparing Databases
Output:
Inserting Record
Output:
The ‘display_above_90’ function is used
to display details of students who have
scored above 90 marks.
Output:
The ‘display_below_33’ function is used
to display details of students who have
scored below 33.
Output:
Deleting records
Original Table
New Table
Menu
The ‘menu’ function displays all the
methods and asks the user what to do
they want to do.
Output: