I have the following config.py:
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or 'sqlite:///' + os.path.join(basedir, 'master.db')
SQLALCHEMY_BINDS = {
'project0': 'sqlite:///' + os.path.join(basedir, 'project0.db')
'project1': 'sqlite:///' + os.path.join(basedir, 'project1.db')
'project2': 'sqlite:///' + os.path.join(basedir, 'project2.db')
}
I need my user to select one of the project db at login. I would like to store this choice in some variable and pass it to the model class.
class Punchlist(db.Model,choice):
__bind_key__ = choice
The db object will be initialised with the default db in __init.py:
app.config.from_object(Config)
db = SQLAlchemy(app)
Which is the optimal way to associate this choice to the user?