computer science activity
computer science activity
Topic
Cover page
Acknowledgement
Main code for
Librarymanagement system
count=0
fOf" 1 in -c ur:
idd•i
count•count+1.
1f count••0!
print( "The-r,e are no available books 11 "')
else:
b_id ■ int(input(·ERter book id to reaove the required
book '"))
cur.execute( .. select • from available_books")
fla1•e
for i in cur:
t_id.t_naae,t_sub.t_quant=i
if t_id=b_id:
flag•l
if flage=1:
cur.execute(·delete from available_book5 where
ld•'·+rtr(b_id)+ .. i")
inydb. co111d t ()
print( .. Oata deleted successfully 11")
else:
print("Please ent,e r correct id 11 ")
id•'·+str(b_id)+"'")
for i ln cur:
t_id,t_name,t_sub,t_quant•-i
flagal
if flag!•l:
print("Please enter the correct id as per the available
books I! ,.)
else:
1f t_quant>e:
s_name•input( '"En1:er student' n..e : ")
s_cl1ss•input("Enter student class: -)
s_doi•input( ·Enter date of issue : "')
s_dor-input(·enter date of ret.ul'"n : '")
cur.e:icecuteC-ins~rt into issued_books
values(' '"+str(b- id)+"'' # ' .. +t- name+• # '"+t- sub+'" ' • "+s- naae+"'' ' ''"+s- clas.s+'" ,. • .. +s
01
•
flag.&
t_id•8
t_na11~e
t_quant-e
c ■e
(1•9
cur.execute("select distinct id fr011 issued_boaks order by
ld'")
fDf" 1 in cur:
if int(1[6] )=b_id:
t_idaint(i[e])
flag+e1
if fla1==e:
p,.int( "No such boOk 1s issued 11 ·)
else:
cur.execute(•select stu_name fr,oa available_books
A,issued_books I where A.id•"'+rtr(t_id)+'" and A,id•I.id and
I. stu_nai.e•' '"+snaine+"' '"')
for i in cur:
t_name-=str(i.[0) )'
c-c+l
if cl •6:
cur.exec11te(·select quantity frOII available_boolcs
·where id•' .. +str(t_id)+•' •)
for j in cur:
t_quant ■ 1nt(j[0])
cl+•l
if clJ ■e:
qua nt=·t_quant-+l
cur.execute("update available_books set
quantity-''"+str(quant)+·· where id-'·+str(t_id)+"'")
cur.execute( ..delete fro. issued_book.s where
id•• "+str(t_id)+"' and stu_name• • •·+t_n,aae+ .. ' ")
mydb. coait()
print(·aook ~•turned successfully II")
else:
print("llo such student has issued this book II")
elif ch••S: WOisplay 8oocs
print("lO , NAME , SUBJECT , QUANTITY")
cur.eKecute( "select • from available_books")
a•cur.fetchall()
for 1 in a:
print(i)
lll)ldb. commit()
ell f Ch=6: #Display 15S Jed Books
print("ID, NAHE, SUBJECT, S_NAME, S_CLASS")
cur.eKecute("select • from issued_books")
a•cur.fetcholl()
for 1 in o:
print(i)
lll)ldb. commit ()
elif ch••7:
break
else:
print("Invalid input I I")
else:
print("Wrong username/password 11 ")
elif c•• 2:
break
else:
print("In11alid input 11" )
Database and Table Description
I 11 I I l·t .,: , r· ,, .1•;•·n1·nt
-- • - - - ♦ -
PRI IW ~-
.. , 1~; IJll c._
•,i"1 tJI I'- .
t 11, ., "~ ! t , ! n t r,11 ..
ti I',-l,·1• 1r
~ 1,· l d
l ·1 l
.ioi-< 11.,rll' .. \ I , 11,11
.,u·c11,11 Pi1 1
•. \l'C l1;1r
:J ,\ ':. ,_. a f l •- ' · •·
·,,.,: I
l;',• !
1 • A Jd r.1111 boob
1 , 11Jr11,ov<11 .,.y t:.cok
J. l a aue bOGt t o e t UIJ~n L
• , M r urn 1~-.;.ol;
!I . VJ. c-v ava Llab l ■ boob
Vic-v la:1i..S boa~
1. I.D9t:rt1 !.
Login
I• llli.ll he I ..I
• , r..a,.... •~ r....-.: ..
I, t,, _. I • ~ ,r~
• . P ~-=rn l:a;.gl
,,. 1• 1111 •vAt J al l• t".;io•.,
&c • ._ , .,. l .....-1 l •.:ob
-y . L, ,.
b •u f""4l c, I C-. 1 l
l"M•M • 1..• t t.h I r:i l r • t
l'M•r l ~ 1 1 I I
IIA!.•t t::tdll . . . . I Ml. Mil t
tllb r •wJ•~l • l"lly• I r 1
&M.•1 <f'UII' 11, I Jn
ea•• 1:..aat • e1 1 • ◄ .r ,,. ,.
~ -,=- • •" '' t e:11 l!nt • I &...1J t1 ■..11 a lt/td • • p•J 't l
,: . . . . . . .. . . •t t ... 1 ... , ltd . ,. _,, ...-. 1, "
IA~•• a-I IJ ' I
"-• •1 - ■- I All ... 'll
LM•• ••l-1
u , • ., .-ua tai.j •
I •- l • I O r
1:a
:..,. u,a- 11 .J • r 11, ,,
to 1 - ••n l t u • 1- •• ~ : lr/11 1 u I r ,.. " _ l.,_ • ,
Jl •• n ,..,. ,. _., tt
bl.!_u r-.ll l!J I J
I f t rfl Sa la ..:'1- 'J ~'
! . M , . a ; : ~ ~ , 0. . . 1
LJ.• •: ttllll.a I l'tUl>-ll O
t.a..:.a% -;..ur...:.t1 1 ' :~
:.· , LE.• •n .,., . ...-:"""l't• 11 t 1J t
:.v r-:u -.n.t t. u • ~ a:> t• tioo:b.! t . ...u lt lft t &>- l 'C t 'ro,.U dllC J. C. a 'f
,:-. . . . . , ... s- • t)• ,-....p .,.,..!I,.., .. =a' . M-1. J J ti
U~ . . l • 11 I 4
CALt 1 . . . . .... I CHIV
t&· •r ._)ff ' 1 a...,,.r..,,
&.atu .....,.u ,-, 1 to
"''• ,,._ ,,...,, • - I lit
i:.. ,.... ,. ""' ao 1• ,_u, ,•
:..
Removing Books
;, ; ~ ,,I I !
. ·. ,1., l
I h,1• 1 '.
,. , · t
~nt ~ r yo ur cho i c~ : 4
Ente r i d o ~ t h~ book t o t ~ r ~ t u.rned : l
En t er ~ e of t:he .st u d<:nt: vho i :13u e d t:he booi: . Nav deep
Bo-o k rt> t: Urn!E" cl a uccP~.!! Eull :,· ! !
Returning Book
• '. •. ,- t
Ir- I•
•• ; ~ •I 'l I I !
~. ,_. t_
tr.le e you. h 0 1 ~ 1 i
: 0 . KM£ , OUII J!XT • I! IIAlC , ol CLA.:i•
o. ' Gs • ;JJI', 'M.ac.h■- 1:.1 0', 'Ar .. '.hcaan' , •t:" . z,, .
d&V"~- . da t • ll O:n. 12 . d•~ c:t - . i.1.A t ■ C2t- ? 3 , .. 21,i
I . Login
2 . E:-:it
l. Login
2.Exit
l.Login
2. Ex.it
Invalid Credentials
1. Add new booktJ
2 . Removo eny book
3 . I~sue book to 5tud~nt
'l . Return book
5 . View available books
6 . View issued books
7. Logout
- - -- - -- ---- - - --- - ---
Enter your choice : 3
Enter book id : 34
Plea~e enter the correct id as per the ovc iloble book~ !!