Refactor `to_sql.rs` to separate files.