ChristopherGS / ultimate-fastapi-tutorial

The Ultimate FastAPI Tutorial
1.03k stars 348 forks source link

Win10 WSL2 Ubuntu 20.04.5 install: fails to create db at step 7 #38

Open bsenftner opened 2 years ago

bsenftner commented 2 years ago

Running "poetry run ./prestart.sh" when on tutorial step 7 (https://christophergs.com/tutorials/ultimate-fastapi-tutorial-pt-7-sqlalchemy-database-setup/) fails with the following error message infinitely repeating:

INFO:__main__:Initializing service INFO:__main__:Starting call to '__main__.init', this is the 1st time calling it. ERROR:__main__:(sqlite3.OperationalError) unable to open database file (Background on this error at: https://sqlalche.me/e/14/e3q8) WARNING:__main__:Finished call to '__main__.init' after 0.000(s), this was the 1st time calling it. INFO:__main__:Starting call to '__main__.init', this is the 2nd time calling it. ERROR:__main__:(sqlite3.OperationalError) unable to open database file (Background on this error at: https://sqlalche.me/e/14/e3q8) WARNING:__main__:Finished call to '__main__.init' after 1.002(s), this was the 2nd time calling it. INFO:__main__:Starting call to '__main__.init', this is the 3rd time calling it.

Following the advice in the "Unable to run the server on Windows #28" issue, I tried running "python3 ./app/backend_pre_start.py" by itself and received the same errors as shown above.

Note that at the time I tried running this first, I did not have SQLite installed on my WSL2 Ubuntu. So I installed SQLite, to see if that makes a difference. It did not.

One additional thing I noticed: after the initial cloning of the git repo, all the source files are read only, and the directories are too. Could that be the issue here?

bsenftner commented 2 years ago

Not sure what changed, but after trying modifying the permissions on the directories it still did not work. As a last resort, I deleted the entire git repository directory tree and re-cloned it. After the re-clone, I went straight to part-07, ran "poetry install" just in case and then "./prestart.sh" and it worked:

(ultimateFastAPI) bsenftner@BlakeStation:~/learnFastAPI/project3/ultimate-fastapi-tutorial/part-07-database$ ./prestart.sh INFO:__main__:Initializing service INFO:__main__:Starting call to '__main__.init', this is the 1st time calling it. INFO:__main__:Service finished initializing INFO [alembic.runtime.migration] Context impl SQLiteImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> da9301b43279, add recipe and user tables INFO:__main__:Creating initial data INFO:__main__:Initial data created

It worked, don't know why it did not before. Hate this type of thing with computers....