I tried something similar to this, but got unexpexcted results. (My skills with SQL is even worse than my skills with Perl.)
# Connect to the database, (the directory containing our csv file(s))
my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;");
# Associate our csv disk file with the table name 'results'
$dbh->{'csv_tables'}->{'info'} = { 'file' => "psinfooutputfile.csv"};
$dbh->{'csv_tables'}->{'hosts'} = { 'file' => "netbiosoutputfile.csv"}
+;
######
my @row = $dbh->selectall_arrayref("SELECT * FROM hosts, info WHERE ho
+sts.IP = info.IP");
print Dumper @row;
Produced
$VAR1 = [
[
'10.160.0.10',
'10.160.0.10',
'10.160.0.10',
'10.160.0.10',
'10.160.0.10',
'10.160.0.10',
'10.160.0.10',
'10.160.0.10',
'10.160.0.10',
'10.160.0.10',
'10.160.0.10',
'10.160.0.10'
],
I am assuming that there is an issue with my SQL.
I figured it out. I need to name each Column in my statement, not just an *.
My problem is that it isn't joining data from one of the tables.
# Connect to the database, (the directory containing our csv file(s))
my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;");
# Associate our csv disk file with the table name 'results'
$dbh->{'csv_tables'}->{'info'} = { 'file' => "psinfooutputfile.csv"};
$dbh->{'csv_tables'}->{'hosts'} = { 'file' => "netbiosoutputfile.csv"}
+;
######
my @row = $dbh->selectall_arrayref("SELECT IP, Domain, ServerName, Day
+sUptime, OS, RAM, OSSP, InstallDate, CPUSpeed, CPUCount, CPUType FROM
+ hosts, info WHERE hosts.IP = info.IP");
print Dumper @row;
Output;
$VAR1 = [
[
'10.160.0.10',
'0',
'',
'19',
'Microsoft_Windows_2000_Server_Domain_Controller',
'1024',
'4',
'12_2_2003',
'995',
'1',
'Intel_Pentium_III'
],
]
UPDATE:
I modified the top line of the file who's data wasn't getting joined and found that the data included there was the ONLY data being used. I changed it to an INNER JOIN and it looks like it's working.