Informatic Practices Project For Class 12
Informatic Practices Project For Class 12
PRINCIPAL
ACKNOWLEDGEMENT
I would like to express my gratitude to my teacher
INFORMATIC PRACTICES Mrs. MERINA PAUL PGT
(CS) for her unrelenting support and valuable
guidance at every step of the project till its
successful completion. I am obliged towards her
motivation throughout the conduct of the project
work.
Regards,
M RAGHAV RAJ
XII-B
INDEX
WHAT IS SQL
ABOUT PYTHON
INTRODUCTION
CODING
OUTPUT IN IDLE
OUTPUT IN MYSQL
SQL
SQL (Structured Query Language)
SQL is a standard language used to manage and
manipulate relational databases. It allows users
to perform various operations like retrieving,
inserting, updating, and deleting data from a
database. SQL is essential for querying and
managing data in relational database
management systems (RDBMS) such as
MySQL, PostgreSQL, and Oracle.
Key SQL Commands:
1. DDL (Data Definition Language):
o CREATE: Used to create a new table or
database.
o ALTER: Modifies the structure of an
existing table (e.g., adding columns).
o DROP: Deletes a table or database.
2. DML (Data Manipulation Language):
Software requirements
Python: version 3.11
Mysql :8.0.29
Internet
CODING
def menu():
c='y'
while (c=='y'):
print ("1. add record")
print("2. update record")
print("3. delete record")
print("4. display records")
print("5. Exiting")
choice=int(input("enter your
choice:"))
if choice == 1:
adddata ()
elif choice== 2:
updatedata ()
elif choice== 3:
deldata ()
elif choice==4:
fetchdata()
elif choice==5:
print("Exiting")
break
else:
print("worng input")
c=input("do you want to continue or
not: ")
def fetchdata():
import mysql.connector
try:
db=mysql.connector.connect(host="loc
alhost",user="root",password='',databa
se='s1')
cursor=db.cursor()
results = cursor.fetchall()
for x in results:
print (x)
except:
print("ERROR: unable to fetch data")
def adddata():
import mysql.connector
db=mysql.connector.connect(host="loc
alhost",user='root',password='',databas
e='s1')
cursor=db.cursor()
cursor.execute("INSERT INTO Garage
VALUES(1,'BMW','M5CS','PETROL','V8','
TWIN TURBO')")
cursor.execute("INSERT INTO Garage
VALUES(2,'AUDI','RS6','PETROL',
'V8','TWIN TURBO')")
cursor.execute("INSERT INTO Garage
VALUES(3,'PORSCHE','911','PETROL','F6'
, 'TWIN TURBO')")
cursor.execute("INSERT INTO Garage
VALUES(4,'TESLA','MODEL S','DUAL
MOTOR','EV','NIL')")
db.commit()
print("Records added")
def updatedata():
import mysql.connector
try:
db=mysql.connetor.connect(host="local
host",user="root",password='',databas
e='s1')
cursor=db.cursor()
sql=("Update Garage set Model=gt3rs
Where name='PORSCHE'")
print("Record Updated")
db.commit()
except Exception as e:
print (e)
def deldata():
import mysql.connector
mysql.connector.connect(host="localho
st",user="root",password='',database='
s1')
cursor=db.cursor()
sql= ("delete form Garage where
name='TESLA'")
cursor.execute(sql)
print("Record Deleted")
db.commit ()
menu()
OUTPUT
RECORD UPDATED
RECORD DELETED
DISPLAY RECORD
EXITING RECORD
Structure of table
Add data
Add data
Update data
delete data