Update app.py
Browse files
app.py
CHANGED
@@ -334,16 +334,14 @@ async def get_dpp_questions(
|
|
334 |
if not os.path.exists(db_path):
|
335 |
raise HTTPException(status_code=404, detail="DPP file not found.")
|
336 |
|
337 |
-
# Connect to the database
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
cursor.execute("SELECT * FROM selected_questions")
|
342 |
-
questions = cursor.fetchall()
|
343 |
-
conn.close()
|
344 |
|
345 |
if not questions:
|
346 |
raise HTTPException(status_code=404, detail="No questions found in the DPP.")
|
|
|
347 |
return {"dpp": dpp_name, "questions": [dict(q) for q in questions]}
|
348 |
|
349 |
# Main application runner
|
|
|
334 |
if not os.path.exists(db_path):
|
335 |
raise HTTPException(status_code=404, detail="DPP file not found.")
|
336 |
|
337 |
+
# Connect to the database asynchronously
|
338 |
+
async with aiosqlite.connect(db_path) as db:
|
339 |
+
cursor = await db.execute("SELECT * FROM selected_questions")
|
340 |
+
questions = await cursor.fetchall()
|
|
|
|
|
|
|
341 |
|
342 |
if not questions:
|
343 |
raise HTTPException(status_code=404, detail="No questions found in the DPP.")
|
344 |
+
|
345 |
return {"dpp": dpp_name, "questions": [dict(q) for q in questions]}
|
346 |
|
347 |
# Main application runner
|