diff options
author | lshprung <lshprung@yahoo.com> | 2021-09-13 16:28:16 -0700 |
---|---|---|
committer | lshprung <lshprung@yahoo.com> | 2021-09-13 16:28:16 -0700 |
commit | d654b5c03c576bf8962960df9febf3ad37e29ea2 (patch) | |
tree | 05725f26906ff0f2b2d6b703ee280ce38e593ac1 /build_playlists.plx | |
parent | 232a02548e314b8cb69d31fd98fe2395ca5520cb (diff) |
Altered behavior of db_cmd and array_handler
Diffstat (limited to 'build_playlists.plx')
-rwxr-xr-x | build_playlists.plx | 9 |
1 files changed, 9 insertions, 0 deletions
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"; + } +} |