NAME

DBIx::RewriteDSN - dsn rewriter for debug

SYNOPSIS

  use DBI;
  use DBIx::RewriteDSN -rules => q{
    dbi:SQLite:dbname=foobar dbi:SQLite:dbname=test_foobar
  };

  ## DBIx::RewriteDSN redefine DBI::connect and 
  ## rewrite dsn passed to DBI::connect
  my $dbh = DBI->connect("dbi:SQLite:dbname=foobar", "", "");

  $dbh->{Name} #=> dbname=test_foobar

External File:

  use DBI;
  use DBIx::RewriteDSN -file => "dbi_rewrite.rules";

  my $dbh = DBI->connect("dbi:SQLite:dbname=foobar", "", "");

DESCRIPTION

DBIx::RewriteDSN is dsn rewriter. This enables rewrite all DBI->connect based on rule text.

CLASS METHODS

use DBIx::RewriteDSN -file => "filename";

Enable rewrites based on rules in filename.

use DBIx::RewriteDSN -rules => "rules";

Enable rewrites based on rules.

If DBI_REWRITE_DSN is false, import does not anything by default.

DBIx::RewriteDSN->disable

Disable rewrites.

DBIx::RewriteDSN->enable

Re-enable rewrites.

DBIx::RewriteDSN->prepend_rules($rules);

Prepend $rules to current rules.

RULES

Rules is like:

  dbi:SQLite:dbname=foobar dbi:SQLite:dbname=foobar_test

  dbi:mysql:database=([^;]+).* dbi:SQLite:dbname=$1

  # fallback
  (.*) dbi:fallback:$1
All empty lines are ignored
Matches are left, replaces are right
All matches are regexp

AUTHOR

cho45 <cho45@lowreal.net>

SEE ALSO

LICENSE

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