Leser: 3
3 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#!/usr/bin/perl use strict; use warnings; use DBI; my $dsn = "DBI:mysql:database=tiet;host=maschine"; my $dbi = DBI->connect($dsn, 'foo', 'bar') or die "Unable to connect to database."; $dbi->do("DELETE FROM tiet_instruments_group"); my $sth = $dbi->prepare("INSERT INTO tiet_instruments_group (group, groupName, instrumentType) VALUES (?, ?, ?)") or die $dbi->errstr; while(my $line = <DATA>) { chomp $line; if(my @values = $line =~ m!^(\w+)\s+([\w\s,]+?)\s+(\w+)$!) { print "@values\n"; $sth->execute(@values) or die $dbi->errstr; } } __DATA__ AFR0 Africa, Near East, Turkey EQU AFR1 Africa, Near East, Turkey EQU AGEN Government Agencies BON ASI0 Asia EQU ASI1 Asia EQU ASI2 Asia EQU ASI3 Asia EQU AST0 Austria EQU AST1 Austria EQU
1
2
3
4
5
6
7
8
9
10
11
12
CREATE TABLE `tiet`.`tiet_instruments_group` (
`id` int(10) unsigned NOT NULL auto_increment,
`group` varchar(16) NOT NULL,
`baseLoad` int(10) unsigned NOT NULL default '0',
`ratio` int(10) unsigned NOT NULL default '0',
`excessTA1` double NOT NULL default '0',
`excessTA2` double NOT NULL default '0',
`excessTA3` double NOT NULL default '0',
`groupName` varchar(128) NOT NULL,
`instrumentType` varchar(16) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
3 Einträge, 1 Seite |