NAME

Log::ger::DBI::Query - Log DBI queries (and results)

VERSION

This document describes version 0.001 of Log::ger::DBI::Query (from Perl distribution Log-ger-DBI-Query), released on 2017-06-19.

SYNOPSIS

 use DBI;
 use Log::ger::DBI::Query;

 # now SQL queries will be logged
 my $dbh = DBI->connect("dbi:...", $user, $pass);
 $dbh->do("INSERT INTO table VALUES (...)");

From command-line:

 % TRACE=1 perl -MLog::ger::Output::Screen -MLog::ger::DBI::Query your-dbi-app.pl

To also log SQL results:

 % TRACE=1 LOG_SQL_RESULT=1 \
     perl -MLog::ger::Output::Screen -MLog::ger::DBI::Query your-dbi-app.pl

Sample log output:

 SQL query: {{INSERT INTO table VALUES (...)}

DESCRIPTION

This is a simple module you can do to log SQL queries for your DBI-based applications.

For queries, it logs calls to prepare(), do(), select*.

For results, it logs calls to do(), select*, fetch*.

Compared to Log::ger::For::DBI, it produces a bit less noise if you are only concerned with logging queries.

ENVIRONMENT

LOG_SQL_QUERY (bool, default 1)

LOG_SQL_RESULT (bool, default 1)

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Log-ger-DBI-Query.

SOURCE

Source repository is at https://github.com/perlancar/perl-Log-ger-DBI-Query.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Log-ger-DBI-Query

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

Log::ger::DBI::QueryResult

Log::ger::For::DBI which logs more methods, including connect(), etc..

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.