cs project 12

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

\ LOYOLA SCHOOL BILASPUR (C.G.

Session(2024-25)
COMPUTER SCIENCE PROJECT ON
DATABASE CONNECTIVITY
ALL INDIA SR.SCHOOL CERTIFICATE EXAMINATION
AISSCE:2024-25

SUBMITTED BY: SUBMITTED TO:


Anuj Kushwaha Mr. Sudhir Naidu
Class : 12 ‘A’
Roll no. :

STUDENT INTERNAL PRINCIPAL EXTERNAL


ACKNOWLEDGMENT

I hereby declare that the project is


completely done by me. As per the
CBSE circulation of AISSCE 2024-
2025. Under the guidance of sir Sudhir
Naidu. This project contains my
original work I can thankful to my
project guider sir Sudhir Naidu, for his
technical support for the completion of
this project as per the AISSCE 2024-
2025.
I thanks to our principal Dr. Fr.
Fabianus Minj, for his whole hearted
support and blessings.
CERTIFICATE

This is to certify that Anuj Kushwaha


of class 12th roll no. student
of Loyola school Bilaspur [C.G] has
satisfactorily completed the computer
science project on database
connectivity. I recommend this project
as a part of fulfilment of annual
computer science practical exam
under AISSCE.

As prescribed by CBSE board 2024-


2025.

Date:
Teacher: Mr. Sudhir Naidu
Principal: Dr. Fr. Fabianus Minj
Summary

This project is a Passenger


Management System for Airports
using Python and MySQL. It allows
users to add, search, update, delete,
and display passenger information
such as name, boarding city,
destination, and flying time. The data
is stored in a MySQL database for
persistence, ensuring it remains
accessible even after the program
ends. The program uses a user-
friendly, menu-driven interface for
easy operation.
import mysql.connector as mycon
try:
conn = mycon.connect(
host="localhost",
user="root",
password="1234",
database="airport"
)
cursor = conn.cursor()
print("Database connected successfully!")
except mycon.Error as e:
print("Error: ",e)
exit()
cursor.execute("""
CREATE TABLE IF NOT EXISTS passengers (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
boarding_city VARCHAR(255),
des na on VARCHAR(255),
flying_ me FLOAT
)
""")
conn.commit()
def inser on():
name = input("Enter the name: ")
from1 = input("Enter the boarding city: ")
dest = input("Enter the des na on: ")
td = float(input("Enter the flying dura on (hrs): "))
cursor.execute("INSERT INTO passengers (name, boarding_city, des na on,
flying_ me) VALUES (%s, %s, %s, %s)", (name, from1, dest, td))
conn.commit()
print("Passenger informa on added successfully!")

def dele on():


name = input("Enter the name to delete: ")
cursor.execute("DELETE FROM passengers WHERE name = %s", (name,))
conn.commit()
print("Passenger deleted successfully!")

def search():
name = input("Enter the name to search: ")
cursor.execute("SELECT * FROM passengers WHERE name = %s", (name,))
result = cursor.fetchall()
if result:
for r in result:
print(r)
else:
print("No passenger found with that name.")

def displayall():
cursor.execute("SELECT * FROM passengers")
results = cursor.fetchall()
if results:
for r in results:
print(r)
else:
print("No passengers in the database.")

def upda on():


name = input("Enter the name to update: ")
new_from = input("Enter the new boarding city: ")
new_to = input("Enter the new des na on: ")
cursor.execute("UPDATE passengers SET boarding_city = %s, des na on = %s
WHERE name = %s", (new_from, new_to, name))
conn.commit()
print("Passenger informa on updated successfully!")

e = """
====================================================
WELCOME
INDIAN AIRWAYS
====================================================
"""
x = """
Choose the op on to proceed:
1. Add Informa on
2. Delete Informa on
3. Edit Informa on
4. Search Passenger
5. Display All Passengers
"""
print(e)
while True:
print(x)
op on = int(input("Enter your op on number: "))
if op on == 1:
inser on()
elif op on == 2:
dele on()
elif op on == 3:
upda on()
elif op on == 4:
search()
elif op on == 5:
displayall()
else:
print("Enter a valid op on!")
con = input("Do you want to con nue (yes/no): ").lower()
if con in ['yes', 'y']:
con nue
else:
print("Thank you for using Indian Airways!")
break
cursor.close()
conn.close()
OUTPUT:

ADD: EDIT:

DISPLAY: DELETE:

SEARCH:

You might also like