put sqlite writes in one transaction. fix problem with FK refelction