Import Reflected Flask-sqlalchemy Module Before Creating The App
This is a continuation of this question. As my flask app should not write anything in my database, I set up Flask-SQLAlchemy to reflect my database. This way I do not have to cha
Solution 1:
I did find a solution (thanks to @snakecharmerb). The solution is simply to avoid the problem, to not import app.models
before running create_app()
. A bit hacky, so feel free to post an answer as well, when you have a better solution.
My test file now looks like this:
# test.py
import unittest
from app import create_app, db
app = create_app()
from app.models import Data
class TestGUI(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.app = app
# etc ...
Post a Comment for "Import Reflected Flask-sqlalchemy Module Before Creating The App"