in reply to How can I get a database handler with Mojolicious::Plugin::Database
Hi frazap
I thought that the way how they solved it in this example was pretty neat:
https://github.com/tempire/MojoExample/blob/master/lib/MojoFull.pm
They set up a helper 'db' inside of the startup method that handles the connection.
Hope this helps,
Veltro
edit And this is how I set up my connection:
my $schema = <YourSchemaLocation>::Schema->connect( "DBI:mysql:database=<DatabaseName>;host=localhost", "<LoginName>", "<Password>", { 'RaiseError' => 1, 'quote_char' => '`', # Needed in case you use reserved sym +bols such as: 'group' is a reserved symbol 'name_sep' => '.' } ) ; # In case you want debugging # $schema->storage->debug( 1 ) ;
Replace <YourSchemaLocation> with your schema, <DatabaseName> with your database, <LoginName> and <Password> with the MySQL credentials that you use.
edit 2: Two more links that could be of interest for you:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I get a database handler with Mojolicious::Plugin::Database
by frazap (Monk) on Apr 03, 2019 at 09:11 UTC | |
by Veltro (Hermit) on Apr 03, 2019 at 10:31 UTC | |
by frazap (Monk) on Apr 03, 2019 at 11:36 UTC | |
by Corion (Patriarch) on Apr 03, 2019 at 09:27 UTC |