You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am new to flask, flask-sqlalchemy, and flask-diamond. My use case is that I would like to use flask-diamond to setup flask and sqlalchemy so that I can use my sqlalchemy database both as part of a web application and from my library and script codes outside of the web application.
In the flask-alchemy documentation, it sounds like one needs to initialize sqlAlchemy's init_app and then create an application context (http://flask-sqlalchemy.pocoo.org/2.1/contexts/). It is not clear to me how much of this is already being done for me in flask-diamond. Can you clarify?
Here is a template, assuming my flask-diamond application is myapplication. It appears to work, so I am guessing that I already have a context to work with.
Can you clarify?
Update
I've traced back through the Diamond code and it looks like, I had things wrong before. To set up to access my flask-diamond database from an outside library or script, I need to do:
# if flask-diamond has scaffolded out a new custom app called myapplication# SETTINGS needs to be already set either in the environment (or via os.environ['SETTINGS'])importmyapplicationapp=myapplication.create_app()
withapp.app_context():
do_stuff_with_app
If others agree this is correct, I can write this up as documentation if there is a place for recipies or how to information.
The text was updated successfully, but these errors were encountered:
Hello,
I am new to flask, flask-sqlalchemy, and flask-diamond. My use case is that I would like to use flask-diamond to setup flask and sqlalchemy so that I can use my sqlalchemy database both as part of a web application and from my library and script codes outside of the web application.
In the flask-alchemy documentation, it sounds like one needs to initialize sqlAlchemy's init_app and then create an application context (http://flask-sqlalchemy.pocoo.org/2.1/contexts/). It is not clear to me how much of this is already being done for me in flask-diamond. Can you clarify?
Here is a template, assuming my flask-diamond application is myapplication. It appears to work, so I am guessing that I already have a context to work with.
Can you clarify?
Update
I've traced back through the Diamond code and it looks like, I had things wrong before. To set up to access my flask-diamond database from an outside library or script, I need to do:
If others agree this is correct, I can write this up as documentation if there is a place for recipies or how to information.
The text was updated successfully, but these errors were encountered: