| 1 | #!/usr/local/bin/perl -w | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use DBIx::RunSQL; | ||
| 5 | |||
| 6 | our $VERSION = '0.28'; | ||
| 7 | |||
| 8 | my $exitcode = DBIx::RunSQL->handle_command_line('myapp', \@ARGV); | ||
| 9 | exit $exitcode; | ||
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | run-db.pl - Run SQL | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | run-sql.pl "select * from mytable where 1=0" | ||
| 18 | |||
| 19 | run-sql.pl --sql create-table.sql | ||
| 20 | |||
| 21 | echo "select * from mytable where 1=0" | run-sql.pl | ||
| 22 | |||
| 23 | =head1 ABSTRACT | ||
| 24 | |||
| 25 | This sets up the database. The following | ||
| 26 | options are recognized: | ||
| 27 | |||
| 28 | =head1 OPTIONS | ||
| 29 | |||
| 30 | =over 4 | ||
| 31 | |||
| 32 | =item C<--user> USERNAME | ||
| 33 | |||
| 34 | =item C<--password> PASSWORD | ||
| 35 | |||
| 36 | =item C<--dsn> DSN | ||
| 37 | |||
| 38 | The DBI DSN to use for connecting to | ||
| 39 | the database | ||
| 40 | |||
| 41 | =item C<--sql> SQLFILE | ||
| 42 | |||
| 43 | The alternative SQL file to use | ||
| 44 | instead of what is passed on the command line. | ||
| 45 | |||
| 46 | =item C<--quiet> | ||
| 47 | |||
| 48 | Output no headers for empty SELECT resultsets | ||
| 49 | |||
| 50 | =item C<--bool> | ||
| 51 | |||
| 52 | Set the exit code to 1 if at least one result row was found | ||
| 53 | |||
| 54 | =item C<--string> | ||
| 55 | |||
| 56 | Output the (single) column that the query returns as a string without | ||
| 57 | any headers | ||
| 58 | |||
| 59 | =item C<--format> formatter | ||
| 60 | |||
| 61 | Use a different formatter for table output. Supported formatters are | ||
| 62 | |||
| 63 | tab - output results as tab delimited columns | ||
| 64 | |||
| 65 | Text::Table - output results as ASCII table | ||
| 66 | |||
| 67 | Text::Table::Any - output results as various formats | ||
| 68 | |||
| 69 | =item C<--force> | ||
| 70 | |||
| 71 | Don't stop on errors | ||
| 72 | |||
| 73 | =item C<--help> | ||
| 74 | |||
| 75 | Show this message. | ||
| 76 | |||
| 77 | =back | ||
| 78 | |||
| 79 | =cut |