18F / rdbms-subsetter

Generates a subset of a relational database that respects foreign key constraints
Creative Commons Zero v1.0 Universal
313 stars 30 forks source link

Allow calling custom code at various points in the extraction process #29

Closed brki closed 8 years ago

brki commented 8 years ago

It would be great to allow calling custom code at various points.

My use case is that I want to add some related rows whenever a row is added, and I'd like to avoid maintaining a forked copy of rdms-subsetter.

It is perhaps possible to satisfy my needs by using the config option, but if I did that it would require creating a definition for each one of 30 tables (and have to remember to update that when a table is added / removed). I could accomplish what I need to do with a few lines of code if I can hook in at the right place.

It seems like these "hooks" could be useful:

and maybe some others.

Perhaps it could work like this:

    if hooks.row_was_added:
        hooks.row_was_added(source_db, source_row, target_db, target_table, prioritized)