vjousse / fastapi-beginners-guide

A complete beginner's guide to FastAPI - Code Samples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docker-compose mode - db.sqlite3 at root - not a persistent storage

vincentporte opened this issue · comments

db.sqlite3 stored at ~/fastapi-beginners-guide, which is map as / in docker container.
This is not a persistent storage.
Need to move database files to ~/fastapi-beginners-guide/db/ and map this dir as /db:/fastapi-beginners-guide/db in docker-compose.yml

quick patch in main.py

# quick and dirty fix for https://github.com/tortoise/tortoise-orm/issues/529
# patch Tortoise's FastAPI contrib module with custom logger
import logging
from tortoise.contrib import fastapi
fastapi.logging = logging.getLogger('uvicorn')
# end of patch


app = FastAPI()

…