Spaces:
Sleeping
Sleeping
ariankhalfani
commited on
Commit
•
e52eead
1
Parent(s):
36fa739
Update app.py
Browse files
app.py
CHANGED
@@ -240,32 +240,6 @@ def download_file(file_format):
|
|
240 |
return html_file_path
|
241 |
else:
|
242 |
raise ValueError("Invalid file format specified.")
|
243 |
-
|
244 |
-
elif choice == "Database (.html)":
|
245 |
-
# Connect to the SQLite database
|
246 |
-
conn = sqlite3.connect(db_file_path)
|
247 |
-
|
248 |
-
try:
|
249 |
-
# Attempt to read the results table into a DataFrame
|
250 |
-
df = pd.read_sql_query("SELECT * FROM results", conn)
|
251 |
-
except pd.errors.DatabaseError as e:
|
252 |
-
# Handle the case where the table doesn't exist
|
253 |
-
conn.close()
|
254 |
-
raise ValueError("Table 'results' does not exist in the database.") from e
|
255 |
-
|
256 |
-
# Close the database connection
|
257 |
-
conn.close()
|
258 |
-
|
259 |
-
# Define the path for the HTML file
|
260 |
-
html_file_path = os.path.join(directory, "results.html")
|
261 |
-
|
262 |
-
# Save the DataFrame as an HTML file
|
263 |
-
df.to_html(html_file_path, index=False)
|
264 |
-
|
265 |
-
# Return the path to the HTML file
|
266 |
-
return html_file_path
|
267 |
-
else:
|
268 |
-
raise ValueError("Invalid choice. Please select a valid format.")
|
269 |
|
270 |
# Initialize the database
|
271 |
init_db()
|
|
|
240 |
return html_file_path
|
241 |
else:
|
242 |
raise ValueError("Invalid file format specified.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
|
244 |
# Initialize the database
|
245 |
init_db()
|