
newbieperlie
New User
Jul 25, 2012, 10:31 AM
Post #1 of 1
(9016 views)
|
Trying to copy database in SQLite to MSSQL
|
Can't Post
|
|
I am trying to copy database after inserting the test results into a file from SQLite to MSSQL The below sub routine is in MSQL.pm sub get_data { undef $/; open (my $QFH, "< /sql/summary.sql") or die "error can't open this file $!"; my $sth= $dbh_oracle->prepare(<$QFH>) or die ("Cannot connect to the database: ".$DBI::errstr."\n"); $sth->execute; close $QFH; my $hash_ref = $sth->fetchall_hashref('MYTABLE'); $sth->finish; return $hash_ref; } And you call it from main and use the output as follows: my $hash_ref = get_data(); my $message = ""; foreach my $table (sort keys %$hash_ref) { $message .= join(":", "Alert", $table, $$hash_ref{$table}{'FLAG'}) . "\n"; } using this in SQLite my $cmd_file = "sqlite3_cmd.txt"; open( FH, ">$cmd_file") or die "Error: ($pgm) Cannot open $cmd_file for writing\n"; print FH $cmd_file; close( FH); my $sqlite = `sqlite3 /projects/wpan_scratch/users/.rsqdb/BCM4345_btfmA0.db < $cmd_file`; # remove create tables $sqlite =~ s/\nCREATE TABLE.*?\);\s*/\n/mgs; $sqlite =~ s/INSERT\s+INTO\s*"test"/INSERT INTO "$tst_table_name"/mgs; $sqlite =~ s/INSERT\s+INTO\s*"regressions"/INSERT INTO "$reg_table_name"/mgs; but i need to know how to call a file in mssql . kindly help me out
|