cbtshare has asked for the wisdom of the Perl Monks concerning the following question:
#Connect to production database and results copy into test #database a +nd update the data my $table_results= $dbh2->prepare("SELECT * from $feed_table WHERE ent +ry_time >= $time"); $table_results->execute(); while(my @results = $table_results->fetchrow_array()) { if(@results) { ##prints out results that should be copied to test database foreach(@results) { print "$_\n"; } } else { print "There is no data for this selec +ted time\n"; } } ##Connect to the test feed database instance and insert data my $destination_host="destination"; my $destination_dsn =DBI:mysql:database=$dbrow;host=$destination_host" +; my $destination_user="root"; my $destination_pass="ol^16"; my $dbh3 = DBI->connect( $from_feed_dsn, $from_feed_user, $fro +m_feed_pass, { RaiseError => 1 }) or die ( "Couldn't connect to datab +ase: " . DBI->errstr ); my $sth_insert = $dbh3->prepare("insert into $feed_table (id_code,entr +y_time,parent_id_code,author_name,author_code,author_url,author_image +_url,entry_url,entry_types, status_code,entry_text,entry_data,last_update,pull_time,queue_code) VA +LUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); while (my $insert = $table_results->fetchrow_array()) { $sth_insert->execute(@$insert);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Database copy table with DBI
by choroba (Cardinal) on Nov 14, 2016 at 07:41 UTC | |
by cbtshare (Monk) on Nov 14, 2016 at 21:34 UTC | |
Re: Database copy table with DBI
by Corion (Patriarch) on Nov 15, 2016 at 11:25 UTC | |
Re: Database copy table with DBI
by poj (Abbot) on Nov 14, 2016 at 08:13 UTC | |
by Random_Walk (Prior) on Nov 15, 2016 at 06:54 UTC | |
by cbtshare (Monk) on Nov 14, 2016 at 21:38 UTC | |
by poj (Abbot) on Nov 14, 2016 at 21:56 UTC | |
by cbtshare (Monk) on Nov 15, 2016 at 03:18 UTC | |
by choroba (Cardinal) on Nov 15, 2016 at 08:31 UTC | |
by poj (Abbot) on Nov 15, 2016 at 10:31 UTC | |
|