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:
In reply to Re: How can I get a database handler with Mojolicious::Plugin::Database
by Veltro
in thread How can I get a database handler with Mojolicious::Plugin::Database
by frazap
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |