[Catalyst] Newbie Question about Database

Robert L Cochran cochranb at speakeasy.net
Tue Jan 20 01:11:36 GMT 2009


John Goulah wrote:
> On Mon, Jan 19, 2009 at 3:10 PM, Giancarlo Corcuera
> <giancarlo at capybara-software.com> wrote:
>   
>> Hi:
>>
>> I'm building an App but I want to have my database in another IP. Is there a
>> way to enter the parameters to do this instead of the normal connection that
>> appears in the manual?
>>
>> This is my model (a very standar one):
>>
>> package App::Model::ModelDB;
>>
>> use strict;
>> use base 'Catalyst::Model::DBIC::Schema';
>>
>> __PACKAGE__->config(
>>   schema_class => 'App::Schema::ModelDB',
>>   connect_info => [
>>       'dbi:mysql:model',
>>       'model',
>>       'model',
>>       {
>>           mysql_enable_utf8   => 0,
>>           on_connect_do       => [
>>               "SET NAMES 'utf8'",
>>               "SET CHARACTER SET 'utf8'",
>>           ],
>>       }
>>   ],
>> );
>>
>> How can I change it to connect to a DB in another IP?
>>
>>     
>
>
> You probably want to do this in the config, something like this:
>
> If the config is yaml
>
> Model::ModelDB:
>      connect_info:
>           - 'dbi:mysql:dbname=my_db_name;host=my_host_or_ip'
>           - 'my_dbuser'
>           - 'my_dbpass'
>           - AutoCommit: 1
>             mysql_auto_reconnect: 0
>
>
> Or if the config is conf
>
> <Model::ModelDB>
>     connect_info   dbi:mysql:dbname=my_db_name;host=my_host_or_ip
>     connect_info   my_dbuser
>     connect_info   my_dbpass
>     <connect_info>
>         AutoCommit   1
>         mysql_auto_reconnect   0
>     </connect_info>
> </Model::ModelDB>
>
>
>
> Thanks,
> John
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
>   
I recommend that you also install the MySQL client software (not
necessarily the whole database engine, but the client component only) on
your computer and then first try to connect to the MySQL server you are
interested in using the MySQL client. That lets you test your
connectivity before you code that into the Catalyst configuration. It is
also great for testing out your SQL statements if you are shaky on SQL
like me.

I also wonder if Catalyst can make use of a .my.cnf file if there is
one. Why is this important? Because you can keep your connection
password private.

Bob Cochran




More information about the Catalyst mailing list