CS Project

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

SUNSHINE CHENNAI SENIOR SECONDARY SCHOOL

(Affiliated to Central Board of Secondary Education, New Delhi)


86/2, AGS Colony, Puzhuthivakkam, Chennai - 91

INVESTIGATORY PROJECT REPORT


20 to 20

NAME
ROLL NUMBER
CLASS & SEC
SUBJECT
TOPIC
SUNSHINECHENNAISENIORSECONDARYSCHOOL
(Affiliated toCentral Board of Secondary Education,New Delhi)
86/2,AGSColony,Puzhuthivakkam,Madipakkam,Chennai-91

BONAFIDECERTIFICATE

Certified to be the bonafide record of the Project Work /


Investigatory Experiment done by Master / Miss
of Class in SUNSHINE CHENNAI SENIOR SECONDARY
SCHOOL, Puzhuthivakkam, Chennai – 600091,year .
.

Submitted for ALL INDIA SENIOR SCHOOL CERTIFICATE


EXAMINATION conducted by CBSE, New Delhi held on
at SUNSHINE CHENNAI SENIOR SECONDARY SCHOOL,
Puzhuthivakkam, Chennai - 600 091 by the candidate bearing the
Registration Number .

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.

Type your text

2
STUDENT MANAGEMENT SYSTEM

Aishwarya.A

Raghav.P

XII A2

3
T a b le o f c o n te n ts :

S.no Topic Page no

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 :

Pythonisa popularprogramming language.It wascreated byGuido vanRossum, and


releasedin1991.

WhatcanPythondo?

● Pythoncanbe usedona server to createweb applications.


● Pythoncanbe usedalongside software tocreate workflows.
● Pythoncanconnect to database systems.It canalsoread and modifyfiles.
● Pythoncanbe usedtohandle big data and perform complex mathematics.
● Pythoncanbe usedforrapid prototyping, orforproduction-readysoftware
development.

WhyPython?

● Pythonworks ondifferent platforms(Windows, Mac, Linux,RaspberryPi, etc).


● Pythonhasa simple syntax similartothe English language.
● Pythonhassyntax that allowsdevelopers to writeprogramswith fewerlinesthan
some otherprogramming languages.
● Pythonrunsonaninterpretersystem, meaning that code canbe executed as soonasit
iswritten. Thismeansthat prototyping can be veryquick.
● Pythoncanbe treated in a procedural way, anobject-oriented way ora functional way.

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 isreleasedunderan open-source license. So you havenothing to pay to useit.

● MySQL isa very powerful program inits own right. It handlesa large subset of the
functionalityofthe most expensiveand powerful database packages.

● MySQL usesa standardform ofthe well-knownSQL data language.

● MySQL worksonmanyoperating systemsand with manylanguagesincludingPHP,


PERL, C,C++, JAVA, etc.

● MySQL worksvery quicklyandworkswell evenwith largedata sets.

● MySQL isvery friendlytoPHP, themost appreciated language for webdevelopment


.
● MySQL supports large databases, up to 50millionrowsormore ina table.

S ys te m re q u ire m e n ts :

6
Hardwarerequirements

● Device:-laptop

● Company:-HP 15s-fr2xxx

● Processor:- 11th Gen Intel®Core™ i3-1115G4 @ 3.00GHz 2.90 GHz

● Installed RAM:-8GB

● System type:-64bit Operating system

● Windows version:-Windows 11

Softwarerequirements

● Python_IDLE shell(Version 3.10-64 bit)

O b jec tiv e :

7
Aim:

The a im o f this pro je ct is to cre a te a stud en t m a n a ge m e nt syste m using


P ytho n a nd SQ L .

Conceptsused:

I ha v e use d c onc e pts o f interfa cing pytho n w ith SQ L .

A lso, a s a n a dd itio na l lea rning , I ha ve trie d to le a rn in d e pth the c onc e pts


o f p a cka g ing a n d using H TM L . So , I h a ve trie d to d ispla y the o utp ut a s a n
H TM L ta b le.

Projectdescription:

The pro je ct is a sim p le stude nt m a na g em ent syste m w ith C R U D – C rea te ,


R ea d ,U pd a te a n d D ele te o pe ra tions.

P ytho n fo rm s the b usiness la ye r o f the pro g ra m a nd M yS Q L is the da ta


la yer. W e ha v e stud ie d bo th o f the se p ro gra m m ing la ng ua g e s sep a ra te ly.
N ow , w e w ill c o nnec t these 2 la ng ua g es.

H ere w e a re using M ySQ L a s b a c k end da ta ba se be ca use o f it is op e n


so urce , fre e a nd po rta b le a nd w ide ly use d . A ny o ne o f m ysq lco nne cto r or
M ySQ L db ca n b e use d fo r d a ta b a se p ro gra m m ing . W e a re using m ysql
c onne c tor.

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 :

1 . Im p ort the c o nnec to r


2 . U se co nne ct m e tho d to c o nnec t to the d a ta b a se
3 . U se cu rsor m e th od to p rep a re the curso r
4 . P re pa re SQ L sta te m en t
5 . Ex ec ute the sta tem e nt
6 . C lo se the co nne ctio n

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 )

c onte nts = '''<!D O C TY P E htm l>


<htm l>

<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 >

<b od y bg c olo r='# 6 58 3 98 '>

13
<h1 > STU D E N T M A N A G E M EN T SY STE M </h 1>

<ta ble b o rde r='1'


b g co lor= 'g ree n'>
<ca p tion >
S TU D EN T D E TA IL S
</ca ptio n>
%s
</ta b le >
</b o dy>

</htm l>

'''% (p )

filen a m e = 'w e bb ro w se r.htm l'

d ef m a in(c onte nts, filena m e):


o utput = o pe n(file na m e ,"w ")
o utput.w rite ("ST UD E N T M A N A G E M E N T SY ST EM ")
o utput.w rite (c onte nts)
o utput.clo se()
m a in(co nten ts, file na m e )
w eb b row se r.op e n(file na m e )

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

de f d ispH TM L (d ='cs2 0 23 '):

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 )

selec t_stud e nt = "SE L EC T * FR O M STU D E N T"


curso r = c o n.c ursor()
curso r.e xe cute (se lec t_stud en t)
result = curso r.fetc ha ll()

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)

co nte nts = '''<!D O C TY P E htm l>


<htm l>

<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>

<bo d y b g co lor='# 65 8 39 8 '>


<h 1> STU D E N T M A N A G E M EN T SY STE M </h1 >

<ta b le b o rd e r='1 '


b g co lo r='gre en '>
<c a p tio n>
ST U DE N T D ET AILS
</ ca p tion>
%s
</ ta ble >
</b od y>

</htm l>

'''% (p)

filena m e = 'w eb b row se r.htm l'

de f m a in(co nte nts, file na m e ):


outp ut = op e n(file na m e ,"w ")
#o utp ut.w rite (" ST U D EN T M A N A G E M E N T S YS TE M ")
outp ut.w rite(co nte nts)
outp ut.c lose ()

m a in(c on tents, filen a m e)


w e b bro w ser.o p en(file na m e)

if(c o n.is_c onn ec ted ()):


curso r.c lo se ()
co n.c lo se ()
print("M yS Q L c onne c tio n is c lo se d.")

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 :

1 . https:// w w w .p yth on.org /

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

3 . https:// w w w .w 3sc ho ols.c o m /htm l/

4 . http s:/ /w w w .g e eksforg ee ks.o rg /p ytho n-m ysql/

19

You might also like