code: def set_database(self, db):
          '''
          Sets the `Database` that this model instance belongs to.
          This is done automatically when the instance is read from the database or written to it.
          '''
          # This can not be imported globally due to circular import
          from .database import Database
          assert isinstance(db, Database), "database must be database.Database instance"
          self._database = df set_database(self, db):
          '''
          Sets the `Database` that this model instance belongs to.
          This is done automatically when the instance is read from the database or written to it.
          '''
          # This can not be imported globally due to circular import
          from .database import Database
          assert isinstance(db, Database), "database must be database.Database instance"
          self._database = db
docs: Sets the `Database` that this model instance belongs to.
          This is done automatically when the instance is read from the database or written to it.