I am trying to learn CGI::Application using this "tutorial":

   <http://people.plusthree.com/~perrin/mvc_slides.swf>

Inside the accompanying application files from:

   <http://people.plusthree.com/~perrin/mvc_samples.tgz>

the example CGI::Application source code uses DBI to connect with MySQL.
I wanted to chance this to use SQLite and I am getting an error.

Here is the original MySQL centric code:

   freebsd% cat DB.pm.orig
   package Poli::DB;

   use strict;
   use warnings;

   use Class::DBI::Loader;

   my $loader = Class::DBI::Loader->new(
       dsn                => 'dbi:mysql:database=poli',
       user               => 'poli',
       password           => 'poli',
       namespace          => 'Poli::DB',
       additional_classes => ['Class::DBI::FromForm'],
       relationships      => 1,
   );

   1;

Here is my changed (SQLite) version.  Changed only in dsn, user, and password:

freebsd% cat DB.pm
   package Poli::DB;

   use strict;
   use warnings;

   use Class::DBI::Loader;

   my $loader = Class::DBI::Loader->new(
       dsn                => 
'dbi:SQLite:database=/home/web/src/mvc/mvc_samples/sql/mvc.sqlite3',
       user               => '',
       password           => '',
       namespace          => 'Poli::DB',
       additional_classes => ['Class::DBI::FromForm'],
       relationships      => 1,
   );

   1;

In my attempt to verify the Perl code of the provided application, I see the 
following:

   freebsd% cat petition.pl
   #!/usr/bin/perl
   use strict;
   use warnings;

   use lib qw(/home/web/src/mvc/mvc_samples/cgiapp/lib);
   use Poli::CGI::Petition;

   my $app = Poli::CGI::Petition->new();
   $app->run();

   freebsd% perl -c petition.pl
   DBI connect('database=/home/web/src/mvc/mvc_samples/sql/mvc.sqlite3','',...)
   failed: unable to open database file at 
/usr/local/lib/perl5/site_perl/5.10.1/Class/DBI/Loader/SQLite.pm line 101
   unable to open database file at 
/usr/local/lib/perl5/site_perl/5.10.1/Class/DBI/Loader.pm line 83
   Compilation failed in require at 
/home/web/src/mvc/mvc_samples/cgiapp/lib/Poli/CGI/Petition.pm line 9.
   BEGIN failed--compilation aborted at 
/home/web/src/mvc/mvc_samples/cgiapp/lib/Poli/CGI/Petition.pm line 9.
   Compilation failed in require at petition.pl line 6.
   BEGIN failed--compilation aborted at petition.pl line 6.

I don't know why SQLite is unable to open the database.  When I run sqlite3 
from the
command line (%sqlite3 /home/web/src/mvc/mvc_samples/sql/mvc.sqlite3) I am able 
to
see the tables created for this application.  While empty at present, I believe 
the
database is constructed properly (per a provided DDL file).

Regards,

web...

--
William Bulley                     Email: w...@umich.edu

72 characters width template ----------------------------------------->|
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to