From d654b5c03c576bf8962960df9febf3ad37e29ea2 Mon Sep 17 00:00:00 2001 From: lshprung Date: Mon, 13 Sep 2021 16:28:16 -0700 Subject: Altered behavior of db_cmd and array_handler --- build_playlists.plx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'build_playlists.plx') diff --git a/build_playlists.plx b/build_playlists.plx index dd8ec9d..1534fbe 100755 --- a/build_playlists.plx +++ b/build_playlists.plx @@ -85,6 +85,7 @@ for (my $i = 0; $i <= $#ARGV; $i++){ } } +# Connect to database file my $dbh = DBI->connect("DBI:SQLite:dbname=$dbname", "", "", { RaiseError => 1}) or die $DBI::errstr; # DEBUG print "Opened database successfully\n"; @@ -94,3 +95,11 @@ $statement = "SELECT count(*) FROM sqlite_master WHERE type='table' AND name='$t if (!db_cmd($dbh, $statement)){ die "Error: table \"$table_name\" does not exist in $dbname"; } + +# If sql mode is turned on, build a playlist based on a query +if ($options{sql}){ + my @db_output = array_handler(db_cmd($dbh, $statement_arg, "SQL_STATEMENT returned successfully")); + for my $i (@db_output){ + print "$i\n"; + } +} -- cgit