| 1 | package Zapp::Task::SQL; | ||
| 2 | 1 | ▶ | use Mojo::Base 'Zapp::Task', -signatures; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use Mojo::File qw( tempdir tempfile ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | ▶ | sub schema( $class ) { | |
|
Subroutine
schema: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 6 | return { | ||
| 7 | 0 | input => { | |
| 8 | type => 'object', | ||
| 9 | required => [qw( sql )], | ||
| 10 | properties => { | ||
| 11 | dsn => { | ||
| 12 | type => 'string', | ||
| 13 | }, | ||
| 14 | username => { | ||
| 15 | type => 'string', | ||
| 16 | }, | ||
| 17 | password => { | ||
| 18 | type => 'string', | ||
| 19 | format => 'password', | ||
| 20 | }, | ||
| 21 | sql => { | ||
| 22 | type => 'string', | ||
| 23 | format => 'textarea', | ||
| 24 | }, | ||
| 25 | }, | ||
| 26 | }, | ||
| 27 | output => { | ||
| 28 | type => 'object', | ||
| 29 | required => [qw( rows count )], | ||
| 30 | properties => { | ||
| 31 | rows => { | ||
| 32 | type => 'array', | ||
| 33 | items => { | ||
| 34 | type => 'object', | ||
| 35 | additionalProperties => { | ||
| 36 | type => 'string', | ||
| 37 | }, | ||
| 38 | }, | ||
| 39 | }, | ||
| 40 | count => { | ||
| 41 | type => 'integer', | ||
| 42 | }, | ||
| 43 | }, | ||
| 44 | }, | ||
| 45 | }; | ||
| 46 | } | ||
| 47 | |||
| 48 | ▶ | sub run( $self, $input ) { | |
|
Subroutine
run: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 49 | 0 | my $dbh = DBI->connect( $input->@{qw( dsn username password )} ); | |
| 50 | 0 | my $rows = $dbh->selectall_arrayref( $input->{sql}, { Slice => {} } ); | |
| 51 | 0 | $self->finish({ | |
| 52 | rows => $rows, | ||
| 53 | count => scalar @$rows, | ||
| 54 | }); | ||
| 55 | } | ||
| 56 | |||
| 57 | 1 | 1; | |
| 58 | |||
| 59 | =pod | ||
| 60 | |||
| 61 | =head1 NAME | ||
| 62 | |||
| 63 | Zapp::Task::SQL | ||
| 64 | |||
| 65 | =head1 VERSION | ||
| 66 | |||
| 67 | version 0.001 | ||
| 68 | |||
| 69 | =head1 AUTHOR | ||
| 70 | |||
| 71 | Doug Bell <preaction@cpan.org> | ||
| 72 | |||
| 73 | =head1 COPYRIGHT AND LICENSE | ||
| 74 | |||
| 75 | This software is copyright (c) 2020 by Doug Bell. | ||
| 76 | |||
| 77 | This is free software; you can redistribute it and/or modify it under | ||
| 78 | the same terms as the Perl 5 programming language system itself. | ||
| 79 | |||
| 80 | =cut | ||
| 81 | |||
| 82 | __DATA__ | ||