Application is running on Azure Container Service
- Using single container, for the site
- Notes for SqlAlchemy
- In the main.py there are two functiomns that open and close the connection to the db.
- You have to manually create the table migrations.
- When using SQLite you need to have the following but it is NOT needed for postgres.
engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
)
- This requires a lot of extra steps to get running on MAC and Ubuntu. The steps are outlined here
- For Mac this should work:
# Step1: install unixodbc
brew install unixodbc
# Step2: install Microsoft ODBC Driver for SQL Server on MacOS
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install msodbcsql mssql-tools
- For the docker image you will likely need to add:
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get -y install msodbcsql17
RUN apt-get -y install unixodbc-dev
uvicorn main:api --reload
docker run -p 8000:8000 fast-api-test:latest
- Did not work with version 14.2 but did with 13.8
Check for App running on port and kill
lsof -i tcp:8000
kill -9 <PID of app>
Get Auto Complete for Jinja2 Templates
- Left click on template directory
- Go to "Mark Directory As" and select template
- It will likely ask you what language you want, select yes.
- The pycharm options will pop up, go to "languages & frameworks"
- Select "Template Language"
- Click on "HTML" in the template file types
- In the "Template language" drop down select Jinja2
- Click Apply then OK
- You do not want to have the html routes in the API docs so use the following in the decorator:
@router.get("/", include_in_schema=False)
Main Difference Between models and Schema
- Models hold info for CRUD ops
- Schema holds info for SQLAlchmey