본문 바로가기

전체 글11

[Fast API] SQLAlchemy로 Oracle DB 연결하기 FastAPI 공식 홈페이지에서는 SQLAlchemy 로 다음 RDBMS 에 연결할 수 있다고 소개한다. PostgreSQL MySQL SQLite Oracle Microsoft SQL Server, etc https://fastapi.tiangolo.com/ko/tutorial/sql-databases/ SQL (Relational) Databases - FastAPI SQL (Relational) Databases Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing. FastAPI doesn't require you to use a S.. 2022. 12. 28.
[Python] object of type int32 is not json serializable 파이썬에서 json을 저장할 일이 있었는데, object of type int32 is not json serializable 오류가 발생했다. 이런 비슷한 오류가 자료형이 numpy의 int32, int64 이거나, datetime 일 경우에도 발생한다. 이는 json의 JSONEncoder가 numpy에서 제공하는 자료형을 기본값으로 변환하기 않기 때문에 발생하는 오류이다. class NpEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, np.integer):# np.integer를 python의 int로 변환 return int(obj) if isinstance(obj, np.floating):# np.floating을 py.. 2022. 12. 27.
[Python] 오늘 날짜 기준 년/월/일 디렉토리 생성 오늘 날짜 확인에는 datetime 모듈이 필요하고, 디렉토리 생성에는 os 모듈이 필요하다. 1. 오늘 날짜 확인 오늘 날짜 정보는 datetime 모듈에서 today() 함수를 호출해서 구할 수 있다. (now() 함수도 활용 가능하며 사용법은 동일함) from datetime import datetime today = datetime.today() print(today) # 2022-12-27 19:26:00.442073 print(type(today)) # 디렉토리 경로를 생성하려면 오늘 날짜 정보를 문자열로 바꿔야 한다. strfrime() 함수를 이용해 %Y(4자리수 년도, 2글자는 %y 활용) , %m(월), %d(일) 정보를 추출해서 문자열로 바꿀 수 있다. dir_name = today... 2022. 12. 27.
[Fast API] PyCharm Community - setting PyCharm Pro 버전에서는 FastAPI 관련 라이브러리 설치와 환경 설정이 자동 실행되어 프로젝트 생성이 수월하지만, Community 버전은 이 기능이 지원되지 않아 사용자가 직접 해야 한다. 1. 프로젝트 생성 새 가상환경에서 프로젝트를 생성한다. (로컬에는 python 3.9이 설치되어 있어 3.9 버전을 기준으로 프로젝트를 생성했다) 2. 라이브러리 설치 python packages 탭에서 fastapi와 uvicorn을 설치한다. 터미널이 익숙한 사람은 다음 명령어로 라이브러리를 설치하면 된다. pip install fastapi pip install uvicorn 3. main.py 파일 생성 디렉토리 내에 main.py 파일을 생성한다. main.py 에는 다음과 같이 작성한다. (공.. 2022. 12. 26.
[React/MUI] MUI 설치 및 사용법 Material UI (MUI)는 Google의 Material Design 을 구현하는 오픈소스 라이브러리이며, 리액트 환경에서 필요한 컴포넌트를 쉽게 사용할 수 있다는 장점이 있다. https://mui.com/ MUI: The React component library you always wanted MUI provides a simple, customizable, and accessible library of React components. Follow your own design system, or start with Material Design. mui.com 1. 설치 터미널에서 npm 일 경우, yarn일 경우 해당되는 명령어로 설치한다. npm install @mui/material @e.. 2022. 12. 25.