FastAPI로 독서 기록 웹 서비스 만들기

안 될 때

· 3 views

1) 테이블을 만들지 않았을 때
바꾸는 상황: schema.sql을 다시 실행하지 않고 앱을 열었습니다.

▼ Code

Path: 콘솔

INFO:     127.0.0.1:60870 - "GET / HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
  ...
sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1146, "Table 'reading_log.book' doesn't exist")


핵심 메시지

(1146, "Table 'reading_log.book' doesn't exist")

뜻: reading_log 데이터베이스에 book 테이블이 없습니다. models.py의 클래스는 테이블을 만들지 않고 짝만 지어 줍니다.
고칠 곳: mysql -u root -p 로 접속해 source sql/schema.sql 을 실행합니다.

2) 템플릿 이름을 잘못 적었을 때
바꾸는 코드: main.py의 "list.html"을 "lists.html"로 바꿉니다.

▼ Code

Path: 콘솔

INFO:     127.0.0.1:60900 - "GET / HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  ...
  File "...main.py", line 18, in book_list
    return templates.TemplateResponse(request, "lists.html", {"books": books})
  ...
jinja2.exceptions.TemplateNotFound: 'lists.html' not found in search path: 'templates'


핵심 메시지

TemplateNotFound: 'lists.html' not found in search path: 'templates'

뜻: templates 폴더에 lists.html이 없습니다. 바로 위의 File 줄이 main.py 18행을 가리킵니다.
고칠 곳: "list.html"로 되돌립니다.

댓글

아직 댓글이 없습니다.