CS Project
CS Project
CS Project
NAME
ROLL NUMBER
CLASS & SEC
SUBJECT
TOPIC
SUNSHINECHENNAISENIORSECONDARYSCHOOL
(Affiliated toCentral Board of Secondary Education,New Delhi)
86/2,AGSColony,Puzhuthivakkam,Madipakkam,Chennai-91
BONAFIDECERTIFICATE
DATE: HEADOFTHEINSTITUTION
SIGNATUREOF
ACKNOWLEDGEMENT
We would like to express our greatest appreciation to all the individuals who have helped and supported
us throughout the project. We are thankful to our principal Mrs. Devika Dinesh and computer science
teacher Mrs.Ishwarya giving us this assignment .A big support during the project , from the initial advice,
and provision of contacts through ongoing advice and encouragement ,which led to the final report of this
computer science project. We wish to thank our parents and classmates who helped in completing the
project by exchanging ideas and sharing opinions without which the project would not have been a
successful one. Sunshine Chennai Senior Secondary School has helped to evolve myself not only as a
computer science student but also as a programmer . It gives me great pleasure for me to undertake this
project .Primarily I thank my dear God for being able to complete this project with success.
2
STUDENT MANAGEMENT SYSTEM
Aishwarya.A
Raghav.P
XII A2
3
T a b le o f c o n te n ts :
1 Introduction to Python 5
2 Introduction to MySQL 6
3 System requirements 7
4 Objective 8
5 Flow chart 9
6 Functions Used 10
7 Source code 12
8 Output Screen 17
9 Conclusion 18
10 Bibliography 19
4
In tro d u c tio n to P y th o n :
WhatcanPythondo?
WhyPython?
5
In tro d u c tio n to M y S Q L :
MySQL isa fast, easy-to-useRDBMS beingused formany small and big businesses. MySQL is
developed, marketed andsupportedbyMySQLAB, which isa Swedish company.MySQL is
becoming sopopularbecause of many good reasons –
● MySQL isa very powerful program inits own right. It handlesa large subset of the
functionalityofthe most expensiveand powerful database packages.
S ys te m re q u ire m e n ts :
6
Hardwarerequirements
● Device:-laptop
● Company:-HP 15s-fr2xxx
● Installed RAM:-8GB
● Windows version:-Windows 11
Softwarerequirements
O b jec tiv e :
7
Aim:
Conceptsused:
Projectdescription:
F lo w c h a rt:
8
F u n c tio n s u s e d :
Cursor object
9
A c ursor o b je ct is ve ry sim ila r to the scre e n curso r, it se rv es a s a lin k
b etw ee n the p ytho n sc ript a nd the SQ L que ry
The M ySQ L C ursor c la ss insta ntia tes o b jec ts tha t c a n ex ec ute
o pe ra tions such a s SQ L sta te m e nts. C urso r ob je cts inte ra ct w ith the
M ySQ L serve r using a M ySQ L C onn ec tio n o bje c t.
Properties:
1 . column_names: returns the list co nta ining the co lum n na m e s o f a
re sult-set.
2 . description: re tu rns the list c on ta ining the d esc rip tion of c olum ns in a
re sult-set.
3 . lastrowid: if there a re a ny a uto-in cre m ente d c o lum n s in the ta b le, this
re tu rns the va lue g e nera te d for tha t c olum n in the la st IN S ER T o r,
U P D A TE op e ra tio n.
4 . rowcount: re turns the num b e r o f row s re turne d/u pd a te d in ca se o f
SE LE C T a nd U P D A TE o p era tio ns.
5 . statement: returns the la st e xe cute d sta te m ent.
Establish connection
W e ca n e sta b lish a c o nnec tion w ith m ysq l d a ta b a se thro ugh
m ysq l.co nne cto r.
im po rt m ysql.c o nnec to r m yd b =m ysql.c o nnec to r.co nne c t(ho st=“lo ca lho st”,
use r=“ro o t”, p a ssw d =“***”, d a ta b a se =“test”) p rin t(m yd b)
P ytho n M ySQ L C o nne cto r pro vid es the fo llo w ing m etho d to m a na g e
d a ta b a se tra nsa c tio ns.
10
Executing queries
W e ha ve to w rite a ny SQ L q uery the n w e ha ve to just p a ss the cre a te
ta b le qu ery in e xe cute () m etho d of c urso r o b je ct.
The ge ne ra l ste ps a re :
11
S o u rc e C o d e :
M a in pro g ra m
im po rt m ysql.c on nec tor
im po rt w e b bro w ser
co n
=m ysq l.co nne cto r.c onne c t(ho st='lo ca lho st',user='roo t',pa ssw o rd= '****',da t
a b a se='a p r20 2 3')
cur= c on .cu rsor()
de f se lec ta ll():
cm d = "selec t * from stud ent"
cur.ex ec ute(cm d)
results =cu r.fe tcha ll()
fo r row in re sults:
p rint(row )
de f inse rt():
c m d = "insert into stud ent v a lu es(% s,% s,% s,% s)"
a = int(in put("En ter roll num b er"))
b = inp ut("E nte r na m e")
c = int(inp ut("E nte r m a rks"))
d = inp ut("Ente r gra d e ")
d a ta = (a ,b ,c,d )
c ur.ex ec ute (c m d,da ta )
c on.co m m it()
de f up d a te():
a = int(in put("En ter m a rks"))
b = int(inp ut("Ente r rollno"))
c m d = "up da te stude nt set m a rks={} w here rollno= {}".fo rm a t(a ,b)
c ur.ex ec ute (c m d)
c on.co m m it()
de f d ele te():
a = int(in put("En ter rollno to be de lete d"))
c m d = "de lete fro m stu de nt w he re ro llno ={}".fo rm a t(a )
c ur.ex ec ute (c m d)
c on.co m m it()
de f d ispH TM L ():
se le ct_ stude nt = "SEL E C T * FR O M STU D E N T "
12
c ursor = co n.c urso r()
c ursor.ex ec ute(sele ct_stu de nt)
resu lt = cu rso r.fetc ha ll()
p = []
tb l = "<tr><td > Ro llN o </td ><td >N a m e </td ><td >M a rks</ td> </tr> "
p .a p pe nd (tb l)
fo r row in re sult:
a = "<tr> <td >% s</ td > "% row [0 ]
p .a p pe nd (a )
b = "<td >% s</ td> "% ro w [1]
p .a p pe nd (b )
c = "<td >% s</td > "% row [2 ]
p .a p pe nd (c )
<he a d>
<title >
H TM L ta ble b g co lor A ttribute
</title >
<style>
ta b le , th, td {
b o rde r: 3 p x so lid b la ck;
}
ta b le {
b o rde r-sp a c ing : 10 p x;
}
tr:nth-c hild (e ve n) {
b a c kgro und -c o lo r: # D 6 EE E E;
}
tr:nth-c hild (o d d) {
b a c kgro und -c o lo r: ligh tgre en;
}
</style>
</he a d >
13
<h1 > STU D E N T M A N A G E M EN T SY STE M </h 1>
</htm l>
'''% (p )
w h ile T rue:
c h = int(in put("E nter 1 - Cre a te 2 -R e a d 3 -U p da te 4- D e lete 5 -D isp la y a s
Ta b le 6-Ex it"))
if c h == 1:
insert()
e lif c h == 2:
se le cta ll()
e lif c h == 3:
up da te()
e lif c h == 4:
d elete ()
e lif c h == 5:
d isp H TM L ()
e lse :
b re a k
14
H TM L ta b le
im po rt m ysql.c on nec tor
im po rt w e b bro w ser
co n = m ysql.c on nec tor.co nne ct(user= 'ro ot', pa ssw o rd='1 4ind ia ',
ho st='lo c a lh ost',da ta ba se =d )
p = []
tbl = "<tr> <td >R o llN o</ td> <td> N a m e</ td> <td> M a rks</td > </tr>"
p.a pp e nd(tb l)
fo r ro w in re sult:
a = "<tr> <td> % s</td >"% ro w [0 ]
p.a pp e nd(a )
b = "<td> % s</td >"% row [1 ]
p.a pp e nd(b )
c = "<td> % s</td >"% ro w [2 ]
p.a pp e nd(c)
<hea d >
<title>
H TM L ta b le b gc o lo r A ttrib ute
</ title >
<style >
ta ble , th , td {
b ord e r: 3 px solid b la ck;
}
ta ble {
b ord e r-sp a cing : 1 0 px ;
}
tr:nth-child (e ve n) {
b a ckg ro und -c olo r: # D 6E E EE ;
15
}
tr:nth-child (o dd ) {
b a ckg ro und -c olo r: lig htg ree n;
}
</style >
</he a d>
</htm l>
'''% (p)
16
O u tp u t S c re e n :
O p tio n1
O p tio n 2
17
O p tio n 4
O p tio n 3
C o n c lu s io n :
Thus a p rojec t ha s b e en co m p lete d using c on ce pts o f P ytho n, SQ L a nd
H TM L ta b les.
18
B ib lio g ra p h y :
2 . h ttp s://w w w .w 3 sc hoo ls.c om / pytho n/p ytho n_m ysq l_ ge tsta rted .a sp
19