improved SQL table sync
Merge pull request #79 from dimagi/sync

improved SQL table sync