srchulo
srchulo

Reputation: 5203

DBIx::Class::Schema::Loader connect to db on different machine

I'm using DBIx::Class:Schema::Loader via the command line to generate schema from my database for DBIx::Class for my Catalyst app. This is the command that I use:

script/myapp_create.pl model DB DBIC::Schema myapp::Schema create=static \
components=TimeStamp,PassphraseColumn dbi:mysql:mydb 'root' '' '{ AutoCommit => 1 }'

However, this command isn't working now because my database is on a separate machine. How do I tell it what IP to connect to? Thanks!

Upvotes: 3

Views: 516

Answers (2)

srchulo
srchulo

Reputation: 5203

I ended up figuring out how to do it. It seems if you pass in another hash after the last one, that hash will be used for your connection information. So simply adding this to the end:

'{host=>"ip_here"}'

Took care of the problem. Here is the command in full:

script/myapp_create.pl model DB DBIC::Schema myapp::Schema create=static \
components=TimeStamp,PassphraseColumn dbi:mysql:mydb 'root' ''           \
'{ AutoCommit => 1 }' '{host=>"ip_here"}'

Upvotes: 2

Alexander Hartmaier
Alexander Hartmaier

Reputation: 2204

The dbi:mysql:... parameter is a normal DBI connect string. After the first : comes the database driver (DBD), after the second the DBD specific parameter. Read the DBD::mysql documentation to find out how to specify a database on a remote machine.

Upvotes: 0

Related Questions