Dancer::Plugin::Database - unable to open database
hello Dancers, I’m trying to use Dancer::Plugin::Database. The database is a sqlite-file that only serves as datafile so I’m not writing to the database in my app. If I run my app on the server with the command ‘perl bin/app.pl’ everything works just fine. All data is shown on the pages as expected. If, however I startup the app while making use of Starman (I took guidance of the article on the perlmaven site) I get the message that the app is unable to open the database. Up until now I worked around the problem to store all my data in json-files and create multiple ‘selection/sorts’ by using hashes and arrays but that is becoming a bit difficult to maintain. The error log gives two lines DBI connect('dbname=all.sqlite','',...) failed: unable to open database file at /home/gertmt/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Dancer/Plugin/Database/Core.pm line 259. Database connection failed - unable to open database file in /home/gertmt/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Dancer/Plugin/Database.pm l. 28 these might explain the problem however I have no idea where to start. Is there someone who had to deal with this issue? Thanks, Gert
Hello Gert Are you sur than Starman are able to read your file all.sqlite ? if all is ok when you launch ./bin/app.pl, check this point and add simple test in Starman.pl |if (-e $all.sqlite) { print "database Exists!\n";| } else { print "Error unable to find database\n"; exit; } Hugues Le 30/05/2014 10:26, Gert van Oss a écrit :
hello Dancers,
I'm trying to use Dancer::Plugin::Database. The database is a sqlite-file that only serves as datafile so I'm not writing to the database in my app. If I run my app on the server with the command 'perl bin/app.pl' everything works just fine. All data is shown on the pages as expected.
If, however I startup the app while making use of Starman (I took guidance of the article on the perlmaven <http://perlmaven.com/getting-started-with-perl-dancer-on-digital-ocean> site) I get the message that the app is unable to open the database. Up until now I worked around the problem to store all my data in json-files and create multiple 'selection/sorts' by using hashes and arrays but that is becoming a bit difficult to maintain.
The error log gives two lines
DBI connect('dbname=all.sqlite','',...) failed: unable to open database file at /home/gertmt/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Dancer/Plugin/Database/Core.pm line 259.
Database connection failed - unable to open database file in /home/gertmt/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Dancer/Plugin/Database.pm l. 28
these might explain the problem however I have no idea where to start. Is there someone who had to deal with this issue?
Thanks, Gert
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hello Hugues, If I put you code in Starman.pl I get a warning in my Vim-editor: $all.sqlite requires explicit package name I have only put reference to the database in the config.yml like so: plugins: Database: driver: "SQLite" database: "all.sqlite" Looking at your test I get the idea that I should have mentioned the database also somewhere in Starman.pl? Thanks, Gert On 30 May 2014, at 10:40, Hugues <hugues@max4mail.com> wrote:
Hello Gert
Are you sur than Starman are able to read your file all.sqlite ?
if all is ok when you launch ./bin/app.pl, check this point and add simple test in Starman.pl
if (-e $all.sqlite) { print "database Exists!\n"; } else { print "Error unable to find database\n"; exit; }
Hugues
Le 30/05/2014 10:26, Gert van Oss a écrit :
hello Dancers,
I’m trying to use Dancer::Plugin::Database. The database is a sqlite-file that only serves as datafile so I’m not writing to the database in my app. If I run my app on the server with the command ‘perl bin/app.pl’ everything works just fine. All data is shown on the pages as expected.
If, however I startup the app while making use of Starman (I took guidance of the article on the perlmaven site) I get the message that the app is unable to open the database. Up until now I worked around the problem to store all my data in json-files and create multiple ‘selection/sorts’ by using hashes and arrays but that is becoming a bit difficult to maintain.
The error log gives two lines
DBI connect('dbname=all.sqlite','',...) failed: unable to open database file at /home/gertmt/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Dancer/Plugin/Database/Core.pm line 259.
Database connection failed - unable to open database file in /home/gertmt/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Dancer/Plugin/Database.pm l. 28
these might explain the problem however I have no idea where to start. Is there someone who had to deal with this issue?
Thanks, Gert
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi Gert, On Fri, 30 May 2014 10:26:46 +0200 Gert van Oss <gertvanoss@me.com> wrote:
I’m trying to use Dancer::Plugin::Database. The database is a sqlite-file that only serves as datafile so I’m not writing to the database in my app. If I run my app on the server with the command ‘perl bin/app.pl’ everything works just fine. All data is shown on the pages as expected.
If, however I startup the app while making use of Starman (I took guidance of the article on the perlmaven site) I get the message that the app is unable to open the database. [...] The error log gives two lines
DBI connect('dbname=all.sqlite','',...) failed: unable to open database file at /home/gertmt/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Dancer/Plugin/Database/Core.pm line 259. [...]
Either the file isn't readable by the user that Starman is running your app as, or the current working dir isn't your app's dir, so you'll need to provide the full path to the DB file in your app config (e.g. /home/gertmt/myapp/all.sqlite or similar). FWIW, I start my Dancer apps using: https://github.com/bigpresh/misc-scripts/blob/master/dancer-init.d/dancer ... and part of the config for each app tells it the app dir, and it passes --chdir $DIR to the start-stop-daemon call it uses to run the app under Starman, which would solve this problem for you I believe. It may be worth me looking at D::P::D to make filenames be relative to the appdir rather than the current working dir, but that could unexpectedly change behaviour for existing users... hmm. -- David Precious ("bigpresh") <davidp@preshweb.co.uk> http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/cpan www.preshweb.co.uk/github
participants (3)
-
David Precious -
Gert van Oss -
Hugues