code: def add_pk_if_required(db, table, name):
      
      db.metadata.reflect(bind=db.engine)
      cls_dict = {'__tablename__': name}
      if not table.primary_key:
          for column in table.columns:
              column.primary_key = True
          Table(name, db.metadata, *table.columns, extend_existing=True)
          cls_dict['__table__'] = table
          db.metadata.create_all(bind=db.engine)
  
      return type(str(name), (sandman_model, db.Model), cls_dict)
docs: Return a class deriving from our Model class as well as the SQLAlchemy
      model.
  
      :param `sqlalchemy.schema.Table` table: table to create primary key for
      :param  table: table to create primary key for