ChristopherGS / ultimate-fastapi-tutorial

The Ultimate FastAPI Tutorial
972 stars 333 forks source link

Part-07 onwards needs some dependency updates #75

Open chen-bowen opened 1 month ago

chen-bowen commented 1 month ago

Hi Chris,

Thank you so much creating this course. As I'm going through the material, I realize the dependencies installation now will have issues with the super old version of SQLAlchemy. I have personally updated the dependencies to make it work on my m2 mac, it would be good to update those dependencies in the repo for people to have the latest version of codebase. I could also help you do it if necessary.

Thanks, Bowen

ejm4567 commented 6 days ago

Bowen: Could you provide a list of what you did to get Part-07 onwards working on a Mac? I am having similar issues in running prestart, either as a Bash script or Python script.

Thanks! --Ed

ejm4567 commented 6 days ago

I solved my issue with prestart.sh not finding app.db.base by defining PYTHONPATH to point to the base of the Part-07 git repo:

export PYTHONPATH=$HOME/Codes/PythonScripts/FastAPI-tutorial/ultimate-fastapi-tutorial/part-07-database

Then Ifound that the Pydantic schema for UserCreate had full_name in app/db/init_db.py but was missing first_name and surname. Adding dummy values for those Optional attributes then allowed prestart.sh to run to completion without error.

` (base) part-07-database % ./prestart.sh INFO:main:Initializing service INFO:main:Starting call to 'main.init', this is the 1st time calling it. /Users/XXX/Codes/PythonScripts/FastAPI-tutorial/ultimate-fastapi-tutorial/part-07-database/./app/backend_pre_start.py:25: RemovedIn20Warning: Deprecated API features detected! These feature(s) are not compatible with SQLAlchemy 2.0. To prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to "sqlalchemy<2.0". Set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings. Set environment variable SQLALCHEMY_SILENCE_UBER_WARNING=1 to silence this message. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9) db.execute("SELECT 1") INFO:main:Service finished initializing INFO [alembic.runtime.migration] Context impl SQLiteImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. /Users/XXX/opt/anaconda3/envs/Py312/lib/python3.12/site-packages/pydantic/_internal/_config.py:334: UserWarning: Valid config keys have changed in V2:

Thanks,

--Ed