Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
# SQL::Interp prints DEBUG to STDERR # whether TRACE_SQL is enabled # SQL::Interp.pm: # my $trace_sql_enabled = $ENV{TRACE_SQL} || 0; # $trace_sql_enabled and print STDERR "DEBUG:interp[sql=$sql,bind=". j +oin(':', @bind) . "]\n"; # TRACE_SQL=1 perl my_script.pl use strict; use warnings; use feature 'say'; use DBIx::LogAny; use DBIx::Simple; use Log::Any::Adapter ('File', './log_file.log'); use SQL::Interp; # connect to your DB using DBIx::LogAny my $dbh = DBIx::LogAny->connect('dbi:SQLite:dbname=file.dat'); # Using an existing database handle (DBIx::LogAny) for DBIx::Simple my $db = DBIx::Simple->connect($dbh); # make your query $db->iquery('SELECT 1')->into(my $one); say $one;
call your script with enabled SQL::Interp SQL Trace:
TRACE_SQL=1 perl my_script.pl DEBUG:interp[sql=SELECT 1,bind=] 1
DBIx::LogAny log output:
[Thu Dec 17 01:15:15 2020] connect(0): dbi:SQLite:dbname=file.dat, , $ +attr = undef; [Thu Dec 17 01:15:15 2020] DBI: 1.643 , DBIx::LogAny: 0.06, Driver: SQ +Lite(1.66) [Thu Dec 17 01:15:15 2020] prepare(0.0): 'SELECT 1' [Thu Dec 17 01:15:15 2020] execute(0.0) [Thu Dec 17 01:15:15 2020] finish(0.0) [Thu Dec 17 01:15:15 2020] finish(0.0)

In reply to Re: Logging and tracing with DBIx::Simple by ablanke
in thread Logging and tracing with DBIx::Simple by kaldor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-23 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found