New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
share/access db connection #101
Comments
My current approach is this.
It works with above configuration, but not sure how things are working behind the scenes. Most of all, not sure whether this is the right approach to solve this issue. |
A |
Closing this now, but please update if you still have any questions. |
@dcrosta Sorry for delayed reply. Having gone through Flask docs you've attached, I decided to add |
Hi, I'm quite new to Flask and struggling with flask-pymongo connection with my Flask app. First of all, following is my overall structure. I've simplified so that it would be more readable.
I'm trying to create a db connection in main.py and use that db client from test.py under resources. main.py and test.py are as follows.
There might have been some typos or syntax error while copy and pasting here. But the thing is that Flask app worked fine until started using flask-pymongo. I googled and made some changes but have failed to solve my problem.
Accoring to Quickstart section in flask-pymongo document, it seems like that I could use db directly in views (which in my case would be resources directory). In my case, however, I get NameError saying that 'mongo not defined'.
What would be nice way to access database client from resources/test.py in my case?
The text was updated successfully, but these errors were encountered: