python flask mongodb test

This commit is contained in:
seemygesture 2025-02-06 16:52:36 +08:00
commit e24e17e42b
8 changed files with 562 additions and 0 deletions

37
README.md Normal file
View file

@ -0,0 +1,37 @@
# Tutorial
## Flask + MongoDB
https://www.digitalocean.com/community/tutorials/how-to-use-mongodb-in-a-flask-application
## MongoDB install
https://www.runoob.com/mongodb/mongodb-window-install.html
### MongoDB Shell
https://www.mongodb.com/try/download/shell
# Setup
## MongoDB (Windows 11)
Install MongoDB.msi
Install MongoDB Shell (.zip) copied under the same directory as MongoDB
Add the above executables to `PATH`
## MongoDB manually startup
```
mongod --dbpath C:\Users\tripl\codes\smg\db\
```
# On another shell launch the shell
```
mongosh
use flask_db
show dbs
db.todos.find()
.quit
```
Can also use the MongoDB Compass GUI.
# Fix
## Poetry
for powershell move poetry from `"AppData\Roaming\Python\Scripts"` to `"\AppData\Local\Programs\Python\<PythonVersion>\Scripts"`
## Poetry shell
Now as a plugin
`poetry self add poetry-plugin-shell`
# TODO
- properly add mongodb authentication and safely connect with secret saved locally