Acrux-DBI

 view release on metacpan or  search on metacpan

lib/Acrux/DBI.pm  view on Meta::CPAN

roll back the transaction unless L<Acrux::DBI::Tx/commit> has been called before
it is destroyed

    # Insert rows in a transaction
    eval {
      my $tx = $dbi->transaction;
      $dbi->query( ... );
      $dbi->query( ... );
      $tx->commit;
    };
    say $@ if $@;

=head2 url

    my $url = $dbi->url;
    $dbi = $dbi->url('sqlite:///tmp/test.db?sqlite_unicode=1');
    $dbi = $dbi->url('sqlite:///./test.db?sqlite_unicode=1'); # '/./' will be removed
    $dbi = $dbi->url('postgres://foo:pass@localhost/mydb?PrintError=1');
    $dbi = $dbi->url('mysql://foo:pass@localhost/test?mysql_enable_utf8=1');

Database connect url

lib/Acrux/DBI/Dump.pm  view on Meta::CPAN

        } elsif ($s =~ /^--.*(?:\n|\z)/p                            # double-dash comment
                or $s =~ /^\#.*(?:\n|\z)/p                          # hash comment
                or $s =~ /^\/\*(?:[^\*]|\*[^\/])*(?:\*\/|\*\z|\z)/p # C-style comment
                or $s =~ /^'(?:[^'\\]*|\\(?:.|\n)|'')*(?:'|\z)/p    # single-quoted literal text
                or $s =~ /^"(?:[^"\\]*|\\(?:.|\n)|"")*(?:"|\z)/p    # double-quoted literal text
                or $s =~ /^`(?:[^`]*|``)*(?:`|\z)/p ) {             # schema-quoted literal text
            $chunk = ${^MATCH};
        } else {
            $chunk = substr($s, 0, 1);
        }
        #say STDERR ">$chunk<";

        # cut string by chunk length
        substr($s, 0, length($chunk), '');

        # marker
        if ($chunk =~ /^--\s+[#]+\s*(\w+)/i) {
            my $_tag = $1 // TAG_DEFAULT;
            push @{$pool->{$tag} //= []}, $buf if length($tag) and $buf !~ /^\s*$/s;
            $tag = $_tag;
            $is_new = 0;

lib/Acrux/DBI/Res.pm  view on Meta::CPAN


See also L<CTK::DBI/table>

=head2 collection

    my $collection = $res->collection;

Fetch all rows from L</"sth"> and return them as a L<Mojo::Collection> object containing hash references

    # Process all rows at once
    say $res->collection->reduce(sub { $a + $b->{money} }, 0);

=head2 collection_list

    my $collection_list = $res->collection_list;

Fetch all rows from L</"sth"> and return them as a L<Mojo::Collection> object containing array references

    # Process all rows at once
    say $res->collection_list->reduce(sub { $a + $b->[3] }, 0);

=head2 columns

    my $columns = $res->columns;

Return column names as an array reference

    # Names of all columns
    say for @{$res->columns};

=head2 err

    my $err = $res->err;

Error code received

=head2 errstr

    my $errstr = $res->errstr;



( run in 2.121 seconds using v1.01-cache-2.11-cpan-df04353d9ac )