[Dbix-class] Re: "Dry-run" for SQL ?

Adam Sjøgren adsj at novozymes.com
Thu Jul 2 14:28:50 GMT 2009


On Tue, 30 Jun 2009 18:35:29 +0200, Robert wrote:

> Is it possible to have a "dry run" mode in DBIx-Class ?

> I just want to see the SQL Statements DBIx would execute, but not want
> DBIx to execute them.

> This way I can verify the statements before executing.

I simply wrap the statements in a transaction and then roll it back at
the end.

Running the code with DBIC_TRACE=1 allows me to see the SQL executed,
and the database isn't changed.

I usually do something like this:

  my $transaction=sub {
      # Manipulate database...
      die "dry run";
  };
  $schema->txn_do($transaction);

Remembering to put the die in there is of course important :-)


  Best regards,

    Adam

-- 
                                                          Adam Sjøgren
                                                    adsj at novozymes.com



More information about the DBIx-Class mailing list