-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReport.py
31 lines (25 loc) · 1.13 KB
/
Report.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
from Checks import *
from Connect import *
from Context import *
from tabulate import tabulate
def generateReport():
data = getReportData()
print('\n\n\n', tabulate(data, headers=['ID', 'Title', 'Year Released', 'Duration(mins)', 'Rating', 'Genre'],tablefmt='presto', numalign='left'), '\n\n')
if input('Enter any key to continue...'): return
def getColumnSelection():
optionList = [ '1', '2', '3', '4' ]
columns = { 1:'yearReleased', 2:'rating', 3:'genre', 4: 'filmID' }
inputText = '\nChoose a Report filter:\n-----------\n1. Year Of Release\n2. Rating\n3. Genre\n4. General report (no filter)\n----: '
selector = input(inputText)
if selector not in optionList:
selector = getvalidatedOption( selector, inputText, optionList)
column = columns[int(selector)]
return column
def getReportData():
column = getColumnSelection()
condition = '%' if column == 'filmID' else inputFromAvailible( column )
queryStr = f'SELECT * FROM tblFilms WHERE LIKE( ?, { column })'
dbCursor.execute( queryStr, [ condition ])
return dbCursor.fetchall()
if __name__ == '__main__':
generateReport()