2008/7/28 Matt S Trout <[EMAIL PROTECTED]>:
> On Mon, Jul 28, 2008 at 02:02:04PM +0100, Peter Flanigan wrote:
>> Dermot wrote:
>> >I don't want to hard-code the path to the SQLite file but unless I do
>> >I am getting DBI Connection failed: unable to open database file(1)
>> >after a login attempt.
>>
>> package YourApp::Model::YourModel;
>>
>> use base qw(Catalyst::Model::DBIC::Schema);
>>
>> __PACKAGE__->config( connect_info => [], schema_class => undef );
>>
I don't want to stray off the topic. I used
<connect_info>
driver dbi:SQLite
file __HOME__/motion.db
</connect_info>
in my conf file to get around a problem with an import script I made
in ~/script/
I needed to s/__HOME__/$HOME/ to allow the script to populate the
SQLite db. This script would be run periodically so it needs to work
in conjunction with everything else.
Admittedly I am sure there is a better way that my effort (see below).
At the very least I could do substitution on the whole string.
...
use FindBin qw($Bin);
use Path::Class;
use lib dir ($Bin,'..','lib')->stringify;
use Config::General;
...
my $config = new Config::General(-ConfigFile => 'MyApp.conf',
-ConfigPath=> \$path, -BackslashEscape => 1);
my %config = $config->getall;
print Dumper $config,"\n";
my $dbfile = $config{'model::MyAppDB'}{'connect_info'}{'file'};
my $HOME = dir($Bin, '..');
$dbfile =~ s/__HOME__/$HOME/;
my $dsn = $config{'Model::DBIC'}{'connect_info'}{'driver'}.':'.$dbfile;
To throw more tinder onto the fire, I am struggling to get Charlie's
solution to work. Charlie's solution was were I started from. The book
had it the same way but in YAML format. I tried
<Model::MyAppDB>
connect_info dbi:SQLite:__HOME__/motion.db
</Model::MyAppDB>
But when I startup the App I get the error:
Couldn't instantiate component "MyApp::Model::MyAppDB", "Can't use string...
It will however start with
<model::MyAppDB>
...
Which I find strange.
Thanx,
Dp.
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]