2

I have an application which needs to connect to and RDS (postgres) proxy with IAM. It makes use of the create_app method.

def create_app():
    connex_app = connexion.App(__name__, specification_dir=base_apispec_dir)
    connex_app.add_api("swagger.yaml", strict_validation=True)

    app = connex_app.app
    app.config.from_object(get_configuration())

    ma.init_app(app)
    db.init_app(app)

    return connex_app

In this post there is an example of how to do this with SQLalchemy, but how do we connect with Flask-SQLAlchemy. In the example they use the @event.listen_for() event from SQLalchemy, but for that I need the engine, which I do not have.

It is possible to get it from the SQLalchemy object, but this gives to following error: No application found. Either work inside a view function or push.

Does anyone know how to make this connection working so the IAM-token can be refreshed every time it expires or just before that?

teuno
  • 61
  • 1
  • 10
  • OP, did you find a solution to this? If so, mind sharing? Thanks! – alexlod Mar 18 '22 at 16:00
  • We did find a solution by using the events. We had a class which we used inside the create_app method (could also be done with and init_app method). Then we got new credentials if the one we had failed. I don't have the code anymore since I don't work for that company anymore. – teuno Dec 14 '22 at 11:34

0 Answers0