1. 파이썬 업데이트 *다운로드

  2. IDE interpreter 설정 전환 fn + F1

  3. 가상환경 설치, (사용, 종료) **가상환경비교 , *설치및사용방법 , *해외-설치방법*

    : 폴더 생성 → vscode로드 → pipenv shell 실행 → 가상환경 세팅 완료

  4. FastAPI

    프레임웍 및 기타 의존성 패키지 설치

    pipenv install fastapi sqlalchemy pymysql uvicorn pymysql importlib-metadata

    헬로월드

    파일생성

    from fastapi import FastAPI
    
    app = FastAPI()
    
    @app.get("/")
    async def root():
        return {"message": "Hello World"}
    

    실행

    uvicorn hello:app

    http://127.0.0.1:8000/

    http://127.0.0.1:8000/docs

  5. superbase에서 db 세팅

    1. id : ********
    2. pw: *********

아, 여기서 잠깐.. 기왕만드는거

혹시 T3 stack 스타일로 만들 수 없을까? 하는 생각에.. 한? 걸음 경로이탈 ㅋㅋ


Vercel로 세팅

https://vercel.com/templates/next.js/nextjs-fastapi-starter

https://github.com/normalstory/nextjs-fastapi-starter

pnpm install

pnpm dev

front http://localhost:3000/

server http://127.0.0.1:8000/

(#덕분에 위 3,4번 과정이 생략됨 ← 물론 실제 서비스 배포 시에는 추가로 염두할 부분이 많음. 학습용)

ORM( Object-Relation Mapping) : **sqlalchemy to prisma,** fastapi-prisma

Prisma

설치 pnpm add prisma --save-dev

프리즈마에 포스트그뤠스큐엘 설치 npx prisma init --datasource-provider postgresql

비로소 프리즈마 Schema 폴더와 .env 파일이 생성된다

.env 설정( Doc, 포스팅)

postgres://postgres:[YOUR-PASSWORD]@db.********.supabase.co:6543/postgres

schema 작성

// This is your Prisma schema file,
// learn more about it in the docs: <https://pris.ly/d/prisma-schema>

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Example {
    id        String   @id @default(cuid())
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
}

pnpm prisma db push

vscode terminal

vscode terminal

superbase dashboard

superbase dashboard

pnpm dev

python - next.js - vercel

python - next.js - vercel

fastapi - prisma - superbase - postgresql

fastapi - prisma - superbase - postgresql