Professional Documents
Culture Documents
Full Project
Full Project
Ahmedabad
A PROJECT REPORT ON
Submitted to Submitted By
CIRTIFICATE
PRINCIPAL
Index
Certificate
Acknowledgement
Introduction
Database description
Source Code
Output
Bibliography
Introduction
Timetable Management
Codes
import mysql.connector as mycon #import mysql.connector
package
import sys
print("|----------|-------|----------|-----------|------
-|-------------------------|")
print("| TTNumber | Class | Section | Day
| Time | Subject |")
print("|----------|-------|----------|-----------|------
-|-------------------------|")
for row in data:
print("| {0:<9d}| {1:<6s}| {2:<9s}|
{3:<10s}| {4:<6s}| {5:<24s}|\
".format(row[0],row[1],row[2],row[3],row[4],row[5]))
print("|----------|-------|----------|-----------|------
-|-------------------------|")
print("Press Enter to continue.")
input()
elif inp == 'U':
print("Update a Record")
ttnum = int(input("Enter Time Table Number
"))
qry = "Select * from timetable where ttnum =
{} order by ttnum".format(ttnum)
cur.execute(qry)
row = cur.fetchone()
count = cur.rowcount
print(count," record is searched
successfully.")
print("|----------|-------|----------|-----------|------
-|-------------------------|")
print("| TTNumber | Class | Section | Day
| Time | Subject |")
print("|----------|-------|----------|-----------|------
-|-------------------------|")
print("| {0:<9d}| {1:<6s}| {2:<9s}|
{3:<10s}| {4:<6s}| {5:<24s}|\
".format(row[0],row[1],row[2],row[3],row[4],row[5]))
print("|----------|-------|----------|-----------|------
-|-------------------------|")
clss = input("Enter Class (New) or . old
value ")
section = input("Enter Section (New) or .
old value ")
day1 = input("Enter Day (New) or . old value
")
time1 = input("Enter Time Table period (New)
or . old value ")
subject = input("Enter Subject (New) or .
old value ")
if clss == '.':
clss = row[1]
if section == '.':
section = row[2]
if day1 == '.':
day1 = row[3]
if time1 == '.':
time1 = row[4]
if subject == '.':
subject = row[5]
qry = "update timetable set clss = '{}',
section = '{}', day1 = '{}',\
time1 = '{}', subject = '{}' where ttnum =
{}".format(clss,section,day1,time1,subject,ttnum)
cur.execute(qry)
con.commit()
count = cur.rowcount
print(count," record is updated
successfully.")
print("Press Enter to continue.")
input()
elif inp == 'D':
print("Delete a Record")
ttnum = int(input("Enter Time Table Number
"))
qry = "Select * from timetable where ttnum =
{}".format(ttnum)
cur.execute(qry)
row = cur.fetchone()
count = cur.rowcount
print(count," record is searched
successfully.")
print("|----------|-------|----------|-----------|------
-|-------------------------|")
print("| TTNumber | Class | Section | Day
| Time | Subject |")
print("|----------|-------|----------|-----------|------
-|-------------------------|")
print("| {0:<9d}| {1:<6s}| {2:<9s}|
{3:<10s}| {4:<6s}| {5:<24s}|\
".format(row[0],row[1],row[2],row[3],row[4],row[5]))
print("|----------|-------|----------|-----------|------
-|-------------------------|")
qry = "delete from timetable where ttnum =
{} order by ttnum".format(ttnum)
cur.execute(qry)
print("Record is deleted successfully.")
con.commit()
count = cur.rowcount
print(count," record is deleted
successfully.")
print("Press Enter to continue.")
input()
elif inp == 'S':
print("Search a Record")
ttnum = int(input("Enter Table Number "))
qry = "Select * from timetable where ttnum =
{} order by ttnum".format(ttnum)
cur.execute(qry)
row = cur.fetchone()
count = cur.rowcount
print(count," record is searched
successfully.")
print("|----------|-------|----------|-----------|------
-|-------------------------|")
print("| TTNumber | Class | Section | Day
| Time | Subject |")
print("|----------|-------|----------|-----------|------
-|-------------------------|")
print("| {0:<9d}| {1:<6s}| {2:<9s}|
{3:<10s}| {4:<6s}| {5:<24s}|\
".format(row[0],row[1],row[2],row[3],row[4],row[5]))
print("|----------|-------|----------|-----------|------
-|-------------------------|")
print("Press Enter to continue.")
input()
elif inp == 'E':
con.close()
print("Terminating Program")
sys.exit(0)
else:
print("Wrong Input Try Again")
print("Press Enter to continue.")
input()
else:
print("Python is not connected to MYSQL
Successfully. Connection Failed.")
sys.exit()
Output
Output Screen
Python Libraries
www.python.org
www.kvspython.com