Home > other >  Flask respectively using Singleton and App Factory created db queries
Flask respectively using Singleton and App Factory created db queries

Time:10-23

Use the Singleton pattern when creating the db:
App=Flask (__name__)
The db=SQLAlchemy (app)
Using multithreaded operations in the background database there is no problem, but use the Factory pattern created:
The db=SQLAlchemy ()
The init_app (app)
Do not use the multithreaded operations in the background database is normal, but using multithreaded operations when the database is prompt error:
Application not registered on the db instance and no application
Excuse me, is what reason, how to solve?
  • Related