Spaces:
Sleeping
Sleeping
ariankhalfani
commited on
Commit
•
6b8b9b8
1
Parent(s):
c7b8556
Update database.py
Browse files- database.py +1 -21
database.py
CHANGED
@@ -78,22 +78,11 @@ def get_db_data(db_path_glaucoma, db_path_cataract):
|
|
78 |
else:
|
79 |
return [], []
|
80 |
|
81 |
-
def get_context_db_data(db_path_context):
|
82 |
-
conn = create_connection(db_path_context)
|
83 |
-
if conn:
|
84 |
-
cursor = conn.cursor()
|
85 |
-
cursor.execute("SELECT * FROM context_info")
|
86 |
-
context_data = cursor.fetchall()
|
87 |
-
conn.close()
|
88 |
-
return context_data
|
89 |
-
else:
|
90 |
-
return []
|
91 |
-
|
92 |
def format_db_data(glaucoma_data, cataract_data, context_data):
|
93 |
""" Format the database data for display """
|
94 |
formatted_data = ""
|
95 |
|
96 |
-
if not glaucoma_data and not cataract_data
|
97 |
return "No data available in the database."
|
98 |
|
99 |
if glaucoma_data:
|
@@ -124,13 +113,4 @@ def format_db_data(glaucoma_data, cataract_data, context_data):
|
|
124 |
|
125 |
formatted_data += "</table>"
|
126 |
|
127 |
-
if context_data:
|
128 |
-
headers = ["ID", "Text Content"]
|
129 |
-
formatted_data += "<h2>Context Data</h2><table border='1'><tr>" + "".join([f"<th>{header}</th>" for header in headers]) + "</tr>"
|
130 |
-
|
131 |
-
for row in context_data:
|
132 |
-
formatted_data += "<tr>" + "".join([f"<td>{row[i]}</td>" for i in range(len(row))]) + "</tr>"
|
133 |
-
|
134 |
-
formatted_data += "</table>"
|
135 |
-
|
136 |
return formatted_data
|
|
|
78 |
else:
|
79 |
return [], []
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
def format_db_data(glaucoma_data, cataract_data, context_data):
|
82 |
""" Format the database data for display """
|
83 |
formatted_data = ""
|
84 |
|
85 |
+
if not glaucoma_data and not cataract_data:
|
86 |
return "No data available in the database."
|
87 |
|
88 |
if glaucoma_data:
|
|
|
113 |
|
114 |
formatted_data += "</table>"
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
return formatted_data
|