Leser: 1
5 Einträge, 1 Seite |
1
2
3
4
5
6
7
mysql> desc tbl_Test;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| test | varchar(255) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $file = 'test.sql';
my ($user,$pass,$db,$host) = ("xx","xx","xx","localhost");
my $dbh = DBI->connect("DBI:mysql:$db:$host",$user,$pass) or die $DBI::errstr;
open my $fh,'<',$file or die $!;
while(my $stmt = <$fh>){
$dbh->do($stmt) or die $dbh->errstr();
}
close $fh;
1
2
3
4
5
6
7
mysql> select * from tbl_Test;
+-------+
| test |
+-------+
| $test |
+-------+
1 row in set (0.00 sec)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#! use /usr/bin/perl;
use strict;
use warnings;
use DBI;
my $result;
my $file = 'testSelect.sql';
my $dbh = DBI->connect("dbi:SQLite:dbname=Test.db","","");
open my $fh, '<', $file or die $!;
while (my $sql = <$fh>)
{
$dbh->do($sql) or die $dbh->errstr();
}
close $fh;
$dbh->disconnect;
5 Einträge, 1 Seite |