-
Notifications
You must be signed in to change notification settings - Fork 0
/
reports.py
47 lines (30 loc) · 1.18 KB
/
reports.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import book
import member
import mysql.connector as sqlt
import pandas as pd
from tabulate import tabulate
import matplotlib.pyplot as plt
con=sqlt.connect(host="localhost",user="root",passwd="Rishi@638963",database="library")
cursor=con.cursor()
def book_output():
df = pd.read_sql("select * from book",con)
print(tabulate(df,headers = 'keys',tablefmt = 'psql',showindex = False))
def member_output():
df = pd.read_sql("select * from member",con)
print(tabulate(df,headers = 'keys',tablefmt = 'psql',showindex = False))
def return_output():
df = pd.read_sql("select * from returns",con)
print(tabulate(df,headers = 'keys',tablefmt = 'psql',showindex = False))
def issue_output():
df = pd.read_sql("select * from issue",con)
print(tabulate(df,headers = 'keys',tablefmt = 'psql',showindex = False))
def col_chart():
q = "select bookid,count(copies) as totalcopies from issue group by bookid;"
df = pd.read_sql(q,con)
print(df)
plt.bar(df.bookid,df.totalcopies)
plt.xlabel("bookid")
plt.ylabel("copies issued")
plt.title("best reading book")
plt.xticks(df.bookid)
plt.show()