in reply to Re^3: DBI:to sort tables according to their dependencies
in thread DBI:to sort tables according to their dependencies
and from the example in Sort::Topological i havemy $sth = $dbh->prepare("select tablename from pg_tables where schema +name=?"); $sth->execute($schema); my @tables; while (my @t = $sth->fetchrow_array) { push @tables, @t; } $sth->finish;
so i am planning something like foreach element in @tables i should call get_deps which will return the contents to be put inside a => 'here'my %children = ( 'a' => [ 'b', 'c' ], 'c' => [ 'x' ], 'b' => [ 'x' ], 'x' => [ 'y' ], 'y' => [ 'z' ], 'z' => [ ], ); sub children { @{$children{$_[0]} || []}; } my @unsorted = ( 'z', 'a', 'x', 'c', 'b', 'y' ); my @sorted = toposort(\&children, \@unsorted);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: DBI:to sort tables according to their dependencies
by marto (Cardinal) on Dec 21, 2011 at 11:02 UTC | |
by ansh batra (Friar) on Dec 21, 2011 at 11:05 UTC | |
by marto (Cardinal) on Dec 21, 2011 at 11:10 UTC | |
by ansh batra (Friar) on Dec 21, 2011 at 11:15 UTC | |
by marto (Cardinal) on Dec 21, 2011 at 11:30 UTC | |
|