Thread SQL Statement aus Text Datei lesen
(3 answers)
Opened by tophoven at 2008-03-22 21:01 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #!/usr/bin/perl use strict; use warnings; use DBI; my $file = 'test.sql'; my $dbh = DBI->connect( ... ) or die $DBI::errstr; open my $fh, '<', $file or die $!; { local $/ = "\n\n"; while( my $statement = <$fh> ){ my $sth = $dbh->prepare( $statement ) or die $dbh->errstr; $sth->execute or die $dbh->errrstr; } } close $fh; test.sql: Code: (dl
)
1 CREATE TABLE testtbl ( OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |