Skip to content

Commit 96e865d

Browse files
fix select statement in extractors for lint error
1 parent 7f943ac commit 96e865d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

backend/app/core/extractors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import tempfile
33
from app.core.db import engine
4-
from sqlmodel import Session
4+
from sqlmodel import Session, select
55
import textract
66
import requests
77
from app.models import Document
@@ -16,7 +16,7 @@ def extract_text_from_file(s3_url: str) -> str:
1616
tmp_file.write(response.content)
1717
tmp_path = tmp_file.name
1818

19-
text = textract.process(tmp_path).decode("utf-8")
19+
text = textract.process(tmp_path).decode("utf-8") or ""
2020

2121
os.remove(tmp_path)
2222

@@ -30,7 +30,9 @@ def extract_text_and_save_to_db(s3_url: str, document_id: str) -> None:
3030
with Session(engine) as session:
3131
text = extract_text_from_file(s3_url)
3232

33-
document = session.query(Document).filter(Document.id == document_id).first()
33+
document_query = select(Document).where(Document.id == document_id)
34+
document = session.exec(document_query).first()
35+
3436
if not document:
3537
raise Exception(f"Document with ID {document_id} not found")
3638

0 commit comments

Comments
 (0)