Some work with FastAPI and SQLAlchemy, including automated alembic migrations
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
from typing import List
|
|
|
|
from pydantic import BaseModel
|
|
|
|
class ItemBase(BaseModel):
|
|
title: str
|
|
description: str = None
|
|
|
|
class ItemCreate(ItemBase):
|
|
pass
|
|
|
|
class Item(ItemBase):
|
|
id: int
|
|
owner_id: int
|
|
|
|
class Config:
|
|
orm_mode = True # pydantic - read dicts or objects (e.g. data["id"] or data.id)
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
email: str
|
|
username: str
|
|
|
|
class UserCreate(UserBase):
|
|
password: str
|
|
|
|
class User(UserBase):
|
|
id: int
|
|
is_active: bool
|
|
items: List[Item] = []
|
|
|
|
class Config:
|
|
orm_mode = True # pydantic - read dicts or objects (e.g. data["id"] or data.id)
|