def get_bind(self, mapper=None, *args, **kwargs):
        """Return the engine or connection for a given model or
        table, using the ``__bind_key__`` if it is set.

        Patch from https://github.com/pallets/flask-sqlalchemy/pull/1001
        """
        # mapper is None if someone tries to just get a connection
        if mapper is not None:
            try:
                # SA >= 1.3
                persist_selectable = mapper.persist_selectable
            except AttributeError:
                # SA < 1.3
                persist_selectable = mapper.mapped_table
            info = getattr(persist_selectable, "info", {})
            bind_key = info.get("bind_key")
            if bind_key is not None:
                state = get_state(self.app)
                return state.db.get_engine(self.app, bind=bind_key)
        return SessionBase.get_bind(self, mapper, *args, **kwargs)
Return the engine or connection for a given model or
        table, using the ``__bind_key__`` if it is set.

        Patch from https://github.com/pallets/flask-sqlalchemy/pull/1001
        
flask_appbuilder/models/sqla/__init__.py