flask-shop
flask-shop copied to clipboard
Enable SQLite `db_type` in both app and test
This PR aims to enable SQLite db_type
in both flask app and pytest. The final code runs without bugs and passes all 16 tests.
Issue:
When running in an environment where no database type (MySQL, Postgresql, etc.) is configured, the project will fail at the database setup. For my Windows11, I did not download MySQL and thus opening my services.msc
results in no service on MySQL. This will lead to Can't connect to MySQL server on '127.0.0.1' ([WinError 10061] 由于目标计算机积极拒绝,无法连接。
in English would be The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused
.
How do I fix:
I modified the settings.py to allow a SQLite database type and I set the default db_type
to SQLite. After solving this, users could run the project without downloading any database services.
Below is the code snippet of changes: