Using Flask-SQLAlchemy
models from a web context involves creating a Flask application and calling
app.test_request_context().push()
Here is what you will do with your non web library. If this is not a problem, if the Flask library is installed, when you need to use the library, then there is no problem using it that way.
If you plan to improve the performance of access code for library data, for example, using different sessions, concurrency, etc., you will modify your source code to be a completely different scenario. In this case, a pure-SQLAlchemy approach might be better, but it really depends on the differences between the two templates.
Typically, models come with methods and using 2 different ORM templates ( Flask-SQLAlchemy
wrapper models and pure SQLAlchemy
) means duplicate code.
source share