def createForeignKeys(tables, ifNotExists=True):
 errors = []
 mapTables = {}
 for table in tables:
  mapTables[table._imdbpyName] = table
 for table in tables:
  _dbschema_logger.info('creating foreign keys for table %s', table._imdbpyName)
  try:
   table.addForeignKeys(mapTables, ifNotExists)
  except Exception as e:
   errors.append(e)
   continue
 return errors

def createForeignKeys ( tables , ifNotExists = True ) : errors = [ ] mapTables = { } for table in tables : mapTables [ table . _imdbpyName ] = table for table in tables : _dbschema_logger . info ( 'creating foreign keys for table %s' , table . _imdbpyName ) try : table . addForeignKeys ( mapTables , ifNotExists ) except Exception as e : errors . append ( e ) continue return errors
create foreign keys .