Skip to content

Instantly share code, notes, and snippets.

@mdellavo
Created June 14, 2017 18:59
Show Gist options
  • Save mdellavo/6293539b006f36ca412de0409c5dd488 to your computer and use it in GitHub Desktop.
Save mdellavo/6293539b006f36ca412de0409c5dd488 to your computer and use it in GitHub Desktop.
def get_dependent_tables_for(table, referenced=None):
referenced = referenced or set([table])
for fk in table.foreign_keys:
other_table = fk.column.table
if other_table not in referenced:
referenced.add(other_table)
get_dependent_tables_for(other_table, referenced=referenced)
return referenced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment