0

I have an app with Flask security. It uses SQLAlchemy and MongoDB (pymongo) I have this configured but when a DB interfering appears (from another app that also uses flask) I have the flask-security defaulting to MongoDB gear instead of SQLAlchemy.

Main question if this somehow could be explicitly set. E.g. Go use SQLAlchemy and not MongoDB for storing your user data...

# config.py
MONGO_URI = 'mongodb://127.0.0.1/somedb'

SQLALCHEMY_DATABASE_URI = 'postgresql://login:password@127.0.0.1/mydb'

How to determine on run time which to use or how to set to one or the other?

garmoncheg
  • 867
  • 11
  • 26
  • I'm not sure what you are asking for. Do you mean that you'd like to determine on run time which to use or how to set to one or the other? – Mike Tung Aug 08 '18 at 17:35
  • Exactly. This is what I have meant. Updated question. Thank you! – garmoncheg Aug 09 '18 at 06:44
  • `if YOUR_CONDITION: user_datastore = SQLAlchemyUserDatastore(db, User, Role) else: user_datastore = MongoEngineUserDatastore(db, User, Role) security = Security(app, user_datastore)` ... – Danila Ganchar Aug 09 '18 at 12:39

0 Answers0