def table_has_constraint(table, name, db):
 t = sa.Table(table, db.metadata, autoload=True, autoload_with=db.engine)
 for c in t.constraints:
  if (c.name == name):
   return True
 return False

def table_has_constraint ( table , name , db ) : t = sa . Table ( table , db . metadata , autoload = True , autoload_with = db . engine ) for c in t . constraints : if ( c . name == name ) : return True return False
utility to find a constraint name in alembic migrations .