I'm new at coding and so here.
Right now I'm creating an perl script, which automatically creates an excel file with the output of an SQL Query.
SQL Query:
init_db_connections();
my @row;
my $curHnd = INV::DBI::execute('----'.':------') or die $INV::DBI::errstr;
while ($row[0] = $curHnd->fetchrow_hashref()) {
printf("Row1: >%s<\n", $row[0]{Row1}),
printf("Row2: >%s<\n", $row[0]{Row2}),
printf("Row3: >%s<\n", $row[0]{Row3})
}
exit 0;
sub init_db_connections {
INV::DBI::init({
------ => '--------',
------- => q{select Row1, Row2, Row3
from table1
}
Create the Excel:
my $workbook = Excel::Writer::XLSX->new( 'perl.xlsx' );
my $worksheet = $workbook->add_worksheet();
my $format = $workbook->add_format();
$format->set_bold();
$format->set_color( 'black' );
$format->set_underline;
my $col = my $row = 0;
$worksheet->write( $row, $col, 'SQL Report', $format );
$workbook->close();
My Problem is now that i don't know how i can combine these two, so that the Query gets automatically pushed into the Excel.
Any Ideas would be great.