0% found this document useful (0 votes)
11 views6 pages

Rupika Homework Project

python

Uploaded by

rupikamohan123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Rupika Homework Project

python

Uploaded by

rupikamohan123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

import mysql.

connector as a

con = a.connect(host="10.183.165.201", user="rupika", passwd="",


database="library_app")

def addbook():
bn = input("Enter Book Name: ")
ba = input("Enter Author's Name: ")
c = int(input("Enter Book Code: "))
t = int(input("Total Books: "))
s = input("Enter Subject: ")
data = (bn, ba, c, t, s)
sql = "insert into books values(%s,%s,%s,%s,%s);"
c = con.cursor()
c.execute(sql, data)
con.commit()
print("\n\n\n nBook Added Successfully..")
wait = input("\n\n\nPress enter to continue\n\n\n")
main()

def issueb():
n = input("Enter Student Name: ")
r = int(input("Enter Reg No.: "))
co = int(input("Enter Book Code: "))
d = input("Enter Date: ")
a = "insert into issue values(%s,%s,%s,%s);"
data = (n, r, co, d)
c = con.cursor()
c.execute(a, data)
con.commit()
print("\n\n\n\nBook issued successfully to: ", n)
wait = input("\n\n\nPress enter to continue....\n\n\n\n\n\n")
bookup(co,1)
main()

def returnb():
n = input("Enter Student Name: ")
r = int(input("Enter Reg No.: "))
co = int(input("Enter Book Code: "))
d = input("Enter Date: ")
a = "insert into returnn values(%s,%s,%s,%s);"
data = (n, r, co, d)
c = con.cursor()
c.execute(a, data)
con.commit()
print("Book returned by: ", n)
wait = input("\n\n\nPress enter to continue....n\n\n\n\n\n")
bookup(co, 2)
main()

def bookup(co, u):


a = "select total from books where bcode=%s;"
data = (co,)
c = con.cursor()
c.execute(a, data)
myresult = c.fetchone()
t=myresult[0]+u
sql = "update books set total=%s where bcode=%s;"
d = (t, co)
c.execute(sql, d)
con.commit()
wait = input("\n\n\nPress enter to continue... \n\n\n\n\n\n")
main()

def dbook():
ac = int(input("Enter Book Code: "))
a = "delete from books where bcode=%s;"
data = (ac,)
c = con.cursor()
c.execute(a, data)
con.commit()
print("Book deleted successfully")
wait = input("\n\n\nPress enter to continue... \n\n\n\n\n\n\n\n\n\n\n\n")
main()

def dispbook():
a = "select * from books;"
c = con.cursor()
c.execute(a)
myresult = c.fetchall()
for i in myresult:
print("Book Name:", i[0])
print("Author:", i[1])
print("Book Code", i[2])
print("Total:", i[3])
print("Subject:", i[4])
print("\n\n")
wait = input("\n\n\nPress enter to continue.... \n\n\n\n\n\n\n\n \n\n\n\n")
main()

def reported_issued_books():
a = "select * from issue;"
c = con.cursor()
c.execute(a)
myresult = c.fetchall()
for i in myresult:
print(myresult)
wait = input("\n\n\nPressenter to continue.....\n\n\n\n\n\n\n\n")
main()

def report_return_books():
a = "select * from returnn;"
c = con.cursor()
c.execute(a)
myresult = c.fetchall()
for i in myresult:
print(myresult)
wait = input("\n\n\nPress enter to continue.....\n\n\n\n\n\n\n\n\n\n\n\n")
main()

def report_menu():
print(""" REPORT MENU 1. ISSUED BOOK 2. RETURNED BOOK 3. GO
BACK TO MAIN MENU \n\n\n""")
choice = input('Enter Task No:......')
if choice == '1':
report_issued_books()
elif choice == '2':
report_return_books()
elif choice == '3':
main()
else:
print("Please try again ..\n\n\n\n\n\n")
main()

def main():
print("LIBRARY MANAGEMENT APPLICATION")
print(
" 1. ADD BOOK 2. ISSUE OF BOOK 3. RETURNOFBOOK 4. DELETE BOO
5. DISPLAY BOOKS 6. REPORT MENU 7. EXIT PROGRAM"
)
choice = input("Enter Task No.:......")
if choice == "1":
addbook()
elif choice == "2":
issueb()
elif choice == "3":
returnb()
elif choice == "4":
dbook()
elif choice == "5":
dispbook()
elif choice == "6":
report_menu()
elif choice == "7":
print(
"\n\n\n\n\n\n\n\n\n\n\n\nThank you and have a great day
ahead......\n\n\n\n\n\n\n\n"
)
else:
print("Please try again.....\n\n\n\n\n\n\n\n\n\n\n\n")
main()

main()

[root@edl-stage-cli-4 ~]# mysql -u rupika


Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 8.0.36 Source distribution

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use library_app;


Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-----------------------+
| Tables_in_library_app |
+-----------------------+
| books |
| issue |
| returnn |
+-----------------------+
3 rows in set (0.00 sec)

mysql> select * from books;


+-------------------------+----------------+-------+-------+---------+
| bname | author | bcode | total | subject |
+-------------------------+----------------+-------+-------+---------+
| The Immortal of Hulusha | Amish Tripathi | 101 | 10 | Fiction |
| The Scam | Suchata Dalal | 102 | 5 | Finance |
+-------------------------+----------------+-------+-------+---------+
2 rows in set (0.00 sec)

mysql> select * from issue;


+------+-------+-------+------------+
| name | regno | bcode | issue_date |
+------+-------+-------+------------+
| Ajay | 501 | 101 | 10-10-2021 |
| David | 502 | 102 | 10-10-2022 |
+------+-------+-------+------------+
2 rows in set (0.00 sec)

mysql>
[root@edl-stage-cli-4 ~]# python rups03.py
LIBRARY MANAGEMENT APPLICATION
1. ADD BOOK 2. ISSUE OF BOOK 3. RETURNOFBOOK 4. DELETE BOO 5.
DISPLAY BOOKS 6. REPORT MENU 7. EXIT PROGRAM
Enter Task No.:......1
Enter Book Name: The Immortal of Hulusha
Enter Author's Name: Amish Tripathi
Enter Book Code: 101
Total Books: 10
Enter Subject: Fiction
nBook Added Successfully..

Press enter to continue

LIBRARY MANAGEMENT APPLICATION


1. ADD BOOK 2. ISSUE OF BOOK 3. RETURNOFBOOK 4. DELETE BOO 5.
DISPLAY BOOKS 6. REPORT MENU 7. EXIT PROGRAM
Enter Task No.:......1
Enter Book Name: The Scam
Enter Author's Name: Suchata Dalal
Enter Book Code: 102
Total Books: 5
Enter Subject: Finance

nBook Added Successfully..

Press enter to continue

LIBRARY MANAGEMENT APPLICATION


1. ADD BOOK 2. ISSUE OF BOOK 3. RETURNOFBOOK 4. DELETE BOO 5.
DISPLAY BOOKS 6. REPORT MENU 7. EXIT PROGRAM
Enter Task No.:......2
Enter Student Name: Ajay
Enter Reg No.: 501
Enter Book Code: 107
Enter Date: 10-10-2021

Book issued successfully to: Ajay

Press enter to continue..

You might also like