Acrux-DBI

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

};
```

Ð’ этом примере модуль модели подключается в основном классе сервера [WWW::Suffit::Server](https://metacpan.org/pod/WWW::Suffit::Server), а экземпляр модели создаётся Ð...

```text
mysql://username:password@hostname/altair?mysql_auto_reconnect=1

mariadb://username:password@hostname/altair?mariadb_auto_reconnect=1

sqlite:///var/lib/altair/altair.db?sqlite_unicode=1
```

Далее указанная URL строка будет преобразована автоматически в DSN будущего соединения

## Connect

При запуске WEB сервера и переходе на главную страницу тестового сайта будет осуществлен "вход" в обработчик этого маршрута `WWW::Altair::Server::Alp...

```perl
my $model = $self->app->model->init;

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

      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

The database connection URL from which all other attributes can be derived.
C<"url"> must be specified before the first call to C<"connect"> is made,
otherwise it will have no effect on setting the defaults.

For using SQLite databases with files relative to current directory you cat use '/./' prefix:

    # '/./' will be removed automatically
    $dbi = $dbi->url('sqlite:///./test.db?sqlite_unicode=1');

Default: C<"sponge://">

=head2 username

    my $username = $dbi->username;

This is the L<Mojo::URL/username> that will be used for generating the connection DSN

default: none

t/05-dump.t  view on Meta::CPAN

};

#$dbi->disconnect; # Disabled this: see autoclean option

done_testing;

1;

__END__

DB_CONNECT_URL='sqlite://./test.db?sqlite_unicode=1' prove -lv t/05-dump.t



( run in 2.383 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )