Save sql file after doing insert wpdb

Trivial! $wpdb->last_query will hold it. 🙂

For more extensive log you might want to define SAVEQUERIES constant to true in configuration. Full log then will be available in $wpdb->queries. It’s off by default for performance reasons.