SQLModels : Python ORM 라이브러리 / SQLAlchemy + Pydantic을 기반으로 만들어진 라이브러리
from sqlmodel import SQLModel, Field
class MyStocks(SQLModel, table=True):
__tablename__ = "MyStocks"
id: int | None = Field(default=None, primary_key=True)
login_id: str = Field(index=True)
quantity: int = Field(default=None)
stock_code: str
avg_price: float = Field(default=0)
access_token: str | None = None
table=True 역할
SQLModel 에게 table model 이라는 사실을 명시해주는 기능.
table=True 을 안해놓으면, data model로 인식함.
table model / data model 이 뭔지는 계속해서 작성..