navalned has asked for the wisdom of the Perl Monks concerning the following question:

I'm having issues with DBIx::Class an SQLite3 database and Dancer2. Everything seems correct, but I'm getting the following error:

[Reporter::App:83114] error @2022-04-06 17:18:50> Route exception: DBI +x::Class::Storage::DBI::_prepare_sth(): DBI Exception: DBD::SQLite::d +b prepare_cached failed: no such table: report [for Statement "INSERT + INTO report ( dest, end_time, fcrdns, rdns, sid, src, start_time) VA +LUES ( ?, ?, ?, ?, ?, ?, ? )"]

The table does indeed exist. Any suggestions on how to debug this.

Replies are listed 'Best First'.
Re: DBIx::Class and Dancer2
by navalned (Beadle) on Apr 06, 2022 at 23:23 UTC

    I've made a little progress. I had my db in the ./lib directory of the app. I moved it to /tmp and used:

    my $schema = My::Class->connect('dbi:SQLite:dbname=/tmp/database.db'); my $record = $schema->resultset('Report')->new(\%data); $record->insert();

    I am now getting the following error:

    DBI Exception: DBD::SQLite::st execute failed: UNIQUE constraint fail +ed: report.id

    This should be an easy fix however, it did actually do the insert into the database.