본문 바로가기
반응형

Python6

개인 프로젝트 리뷰 - oath2 2 FASTAPI Pydantic pydantic module 의 정의 Data validation and settings management using Python type annotations. pydantic enforces type hints at runtime, and provides user friendly errors when data is invalid. Define how data should be in pure, canonical Python; validate it with pydantic. 내가 정의한 pydantic schema.py 파일 class UserBase(BaseModel): username: str class UserCreate(UserBase): hashed_passwor.. 2022. 11. 17.
개인프로젝트 리뷰 - oauth 1 WEB(FE) 에서 User Login / Register 를 위해 Backend API 서버를 호출하여 사용자 로그인 및 생성을 진행합니다. API 는 모두 FastAPI 를 통해 만들어 졌습니다. Folder 구조는 이미지와 같으며 Main = API 정의된 함수 Crud = Main 에서 사용하는 함수의 Sub Function Database = DB Connection 정보 Models = ORM 을 위한 정의 Schemas = pydantic 사용을 위한 정의 로 구분되어 있습니다. 우선 첫 번째로 Database 설정을 알아 보겠습니다. - 패키지 설치 pip install sqlalchemy - 코드 리뷰 from sqlalchemy import create_engine from sqlalc.. 2022. 10. 31.
개인 프로젝트 리뷰 - Pandas, Pymysql 파일은 xlsx 형식으로 다운로드 되었고, 해당 파일에서 필요한 부분을 선택하여 Database 에 적재하는 작업이 남았습니다. ford_excel_1 = glob2.glob('/data/mail/*.xlsx') 첫 번째로 파일을 읽습니다. def insert_db(): conn = pymysql.connect(host=db_host,user=db_user,password=db_pass,db=db_name,charset='utf8') cur = conn.cursor() sql = "insert into usage (id, date, franchisee, used) value (%s, %s, %s, %s)" for file in ford_excel_1: df = pd.read_excel(file,skipr.. 2022. 10. 30.
개인 프로젝트 리뷰 - Crawling Mail 프로젝트 상에서 사용되는 파일은 (금융사에서 전달하는 Mail 파일)은 HTML 로 제공되고 있습니다. 하여 해당 HTML 파일을 열고, 제가 원하는 xlsx 로 다운받는 Function 을 찾아 클릭해야 합니다. 이를 위해 selenium 을 사용하였고, Chrome 보다는 가벼운 Firefox 를 사용하였습니다. ford_html = glob2.glob('/data/mail/*.html') ago_date = datetime.date.today() - timedelta(days=30) down_dir = "/data/mail/" ## pvc 경로 binary = FirefoxBinary('/opt/firefox/firefox') 매월 새로운 파일만을 작업하기 위해 시간을 설정하였고, glob2 를 통.. 2022. 10. 30.