def generic_find_constraint_name(table, columns, referenced, db):
 t = sa.Table(table, db.metadata, autoload=True, autoload_with=db.engine)
 for fk in t.foreign_key_constraints:
  if ((fk.referred_table.name == referenced) and (set(fk.column_keys) == columns)):
   return fk.name

def generic_find_constraint_name ( table , columns , referenced , db ) : t = sa . Table ( table , db . metadata , autoload = True , autoload_with = db . engine ) for fk in t . foreign_key_constraints : if ( ( fk . referred_table . name == referenced ) and ( set ( fk . column_keys ) == columns ) ) : return fk . name
utility to find a constraint name in alembic migrations .