08-02-2023, 04:26 PM
Basically, I am trying to share as much database layer code as possible between a Flask application (for a REST API) and a *non-Flask* API.
Is it a good idea to use the same [Flask-SQLAlchemy][1] layer in both the pure Python API (intended to be imported in non-web Python applications) and in the REST API Flask daemon?
I guess another way to phrase, though I am not sure on the terminology, "how do I best share database model between Flask app and a separate Python import library?"
<hr/>
Or from another angle, is there any point in using [Flask-SQLAlchemy][2] in a Flask REST API, if you also want to share the SQL abstraction with an import library. Is it better then to use plain [SQLAlchemy][3]?
<hr/>
Use case: we have a large database with many tables, and want to build both a REST API (for customer access) and a Python import library (for performant internal tools) for accessing the database, but of course share as much code between them as possible.
Related:
-
[1]:
Is it a good idea to use the same [Flask-SQLAlchemy][1] layer in both the pure Python API (intended to be imported in non-web Python applications) and in the REST API Flask daemon?
I guess another way to phrase, though I am not sure on the terminology, "how do I best share database model between Flask app and a separate Python import library?"
<hr/>
Or from another angle, is there any point in using [Flask-SQLAlchemy][2] in a Flask REST API, if you also want to share the SQL abstraction with an import library. Is it better then to use plain [SQLAlchemy][3]?
<hr/>
Use case: we have a large database with many tables, and want to build both a REST API (for customer access) and a Python import library (for performant internal tools) for accessing the database, but of course share as much code between them as possible.
Related:
-
[To see links please register here]
-[To see links please register here]
- [SQLAlchemy with Flask -- hybrid models?][4][1]:
[To see links please register here]
[2]:[To see links please register here]
[3]:[To see links please register here]
[4]:[To see links please register here]