On Fri, Mar 12, 2010 at 10:51 AM, William Bulley <[email protected]> wrote:
> 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',
I have no idea how Class::DBI works, but from the DBD::SQLite docs,
the correct DSN string for sqlite is
DBI->connect("dbi:SQLite:dbname=$dbfile","","");
Note, 'dbname' instead of 'database'
That said, you may be making things too hard for yourself. I use
CGI::Application::Plugin::DBH, and it just works.
Finally, note there is a CGI::Application mailing list, for CGI::App
questions. That may be more suitable than this more sqlite-focused
list.
> 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: [email protected]
>
> 72 characters width template ----------------------------------------->|
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
--
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users