프레임워크/FastAPI 25

[FastAPI] FastAPI [25] SQL (Relational) Databases (2)

https://fastapi.tiangolo.com/tutorial/sql-databases/ SQL (Relational) Databases - FastAPI SQL (Relational) Databases FastAPI doesn't require you to use a SQL (relational) database. But you can use any relational database that you want. Here we'll see an example using SQLAlchemy. You can easily adapt it to any database supported by SQLAlchemy, l fastapi.tiangolo.com * 공식문서 순서상으론 Dependencies(의존성)..

[FastAPI] FastAPI [24] SQL (Relational) Databases (1)

https://fastapi.tiangolo.com/tutorial/sql-databases/ SQL (Relational) Databases - FastAPI SQL (Relational) Databases FastAPI doesn't require you to use a SQL (relational) database. But you can use any relational database that you want. Here we'll see an example using SQLAlchemy. You can easily adapt it to any database supported by SQLAlchemy, l fastapi.tiangolo.com * 공식문서 순서상으론 Dependencies(의존성)..

[FastAPI] FastAPI [22] JSON Compatible Encoder

JSON Compatible Encoder - FastAPI JSON Compatible Encoder There are some cases where you might need to convert a data type (like a Pydantic model) to something compatible with JSON (like a dict, list, etc). For example, if you need to store it in a database. For that, FastAPI provides a js fastapi.tiangolo.com 0. JSON Compatible Encoder Pydantic model과 같은 데이터 자료형을 JSON과 비교가능한 어떠한 것(dict, list, e..

[FastAPI] FastAPI [20] Handling Errors

Handling Errors 내 API 사용자에게 에러발생을 알려줘야하는 많은 상황이 있다. 이 사용자는 프론트엔드 브라우저 유저나 사물인터넷 사용자 등등이 될 수 있다. 우리는 다음과 같은 상황에서 에러발생을 사용자에게 알려야 한다. 사용자는 operation을 실행할 충분한 권한이 없다. 사용자는 자원에 접근할 권한이 없다. 사용자가 접근하려는 item이 존재하지 않는다. etc. 이러한 상황에서 우리는 일반적으로 HTTP 상태코드 400~499를 반환해줘야 한다. HTTP 상태코드 200~299가 '성공'의 의미를 담고있는것과는 반대이다. HTTP 상태코드 400~499는 error가 존재함을 의미한다. "404 Not Found" error를 본적이 있다면 이해하기 쉽다. 다음 예시들을 통해, 예..

[FastAPI] FastAPI [18] Request Files

https://fastapi.tiangolo.com/tutorial/request-files/ Request Files - FastAPI Request Files You can define files to be uploaded by the client using File. Info To receive uploaded files, first install python-multipart. E.g. pip install python-multipart. This is because uploaded files are sent as "form data". Import File Import File a fastapi.tiangolo.com 0. Request Files File 라이브러리를 사용하여 클라이언트가 파일..