#!/usr/bin/perl open (SQL_FILE, ">load.sql"); #the argument numbers supplied to create_insert are the number of seconds offset from 2007-01-01 (start seconds, stop seconds) #if you want to perform transaction batches, you can uncomment the BEGIN/COMMIT statements and run several create_insert commands #with the effective ranges &create_insert(657000,667000); close (SQL_FILE); exit 0; ######################## sub create_insert { #print SQL_FILE "BEGIN;\n"; my ($start_id,$stop_id) = @_; for (my $i = $start_id; $i < $stop_id; $i++) { my $date_converted_1 = `date --date='2007-01-01 00:00:00 +0000' +%s` + $i; my $date_converted_2 = `date -u -d '1970-01-01 $date_converted_1 seconds' +"%Y-%m-%d %H:%M:%S"`; chomp($date_converted_2); #print $date_converted_2."\n"; $this_sql = "insert into multi_obs(platform_handle,sensor_id,m_type_id,m_date) values ('ndbc:test1:drifter',191,41,'$date_converted_2');\n"; print SQL_FILE $this_sql; } #print SQL_FILE "COMMIT;\n"; }