-
Notifications
You must be signed in to change notification settings - Fork 0
/
show.py
58 lines (42 loc) · 2.17 KB
/
show.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
48
49
50
51
52
53
54
55
56
57
58
"""
This script provides classes for displaying information from a database. It includes the following classes:
- Show: The base class for displaying information.
- available_courses(): Displays all available courses from the "COT" table.
- student_information(): Displays information about a specific student based on their ID.
- AdminShow: Inherits from Show class and includes an additional method for displaying tables.
- show_tables(): Displays all rows from a specified table based on user input.
- UserShow: Inherits from Show class. Currently does not have any additional methods.
Note: The script uses the Connection class from the connections module to establish a connection with the database and execute SQL queries.
To use the script, create an instance of the desired class and call the appropriate method to display the information.
"""
from connections import Connection
class Show:
def available_courses(self):
database_connection = Connection()
query = f"SELECT * FROM COT"
cursor, connection = database_connection._open()
database_connection._execute(cursor, connection, query, "")
database_connection._fetch(cursor)
database_connection._close(cursor,connection)
# it is about fetching all the cources and print it
def student_information(self, student_id):
database_connection = Connection()
value = student_id
query = f"SELECT * FROM STT WHERE STT.STID = {value}"
cursor, connection = database_connection._open()
database_connection._execute(cursor, connection, query, "")
database_connection._fetch(cursor)
database_connection._close(cursor,connection)
class AdminShow(Show):
def show_tables(self):
database_connection = Connection()
value = input("\nenter your table name: ")
query = f"SELECT * FROM {value}"
cursor, connection = database_connection._open()
database_connection._execute(cursor, connection, query, "")
database_connection._fetch(cursor)
database_connection._close(cursor,connection)
class UserShow(Show):
pass
# show = AdminShow()
# show.available_courses()