[Catalyst] DBI Exception: DBD::SQLite::db prepare_cached failed

J. Shirley jshirley at gmail.com
Fri Oct 10 05:48:09 BST 2008


On Thu, Oct 9, 2008 at 9:00 PM, Proud Dzambukira <proudd at gmail.com> wrote:
> Hi,
>
> I am very new to Catalyst and have found it pretty exciting so far. I have a
> very basic "People" database table and whenever I try to run the following
> script:
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use lib qw( lib ../lib );
>
>
> use Markets::Schema::MarketDB;
> use Markets::Model::MarketDB;
>
> # demonstrate picking up database connection info
> my $connect_info = Markets::Model::MarketDB->config->{connect_info};
> print "connecting schema to ".$connect_info->[0]."\n";
>
> # connect to the Catalyst schema
> my $schema = Markets::Schema::MarketDB->connect( @$connect_info );
>
>
> # list all People
> print "listing all People\n";
> my $rs = $schema->resultset('People')->search({});
> for my $row ( $rs->all ){
>   print "\nPerson ". $row->id ."\t - Name " . $row->first_name . "\n";
> }
>
> 1;
>
> from .../markets/script/test.pl I get the following error:
>
> connecting schema to dbi:SQLite:database
> listing all People
> DBIx::Class::ResultSet::all(): DBI Exception: DBD::SQLite::db prepare_cached
> failed: no such table: people(1) at dbdimp.c line 271 [for Statement "SELECT
> me.id, me.first_name, me.last_name FROM people me"] at test.pl line 26
>
> It seems I am successfully connecting but failing to read from my database?
> Any ideas what I may be doing wrong? Please help!


A couple things wrong:

1) This is a DBIx::Class problem, of which there is a separate list.
This is for Catalyst, the MVC framework.  You can subscribe to that
list at http://lists.scsys.co.uk/mailman/listinfo/dbix-class/

2) You haven't deployed your database.  The table doesn't exist.  When
you get an error that says "no such table: people" the problem is
quite clearly defined.  There is no such table.
You can read about deploying here:
http://search.cpan.org/~ash/DBIx-Class-0.08010/lib/DBIx/Class/Schema.pm#deploy

Thanks,
-J

-- 
J. Shirley :: jshirley at gmail.com :: Killing two stones with one bird...
http://www.coldhardcode.com



More information about the Catalyst mailing list