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

I decided to play around with DBIx::Class, and Im missing something. I'm having trouble connecting to a sqlite db. I can connect to the db in question using DBI, as follows:

my $dbpath = 'C:/my/path/stats.db'; my $dsn = "dbi:SQLite:$dbpath"; my $dbh = DBI->connect( $dsn, '', '', { RaiseError => 1, AutoCommit => + 1 } );

To use DBIx::Class, I created a file that contains:

package My::Schema; use strict; use warnings; use base qw/DBIx::Class::Schema::Loader/; __PACKAGE__->loader_options( relationships => 1 ); 1;
which I then use as follows:
package My::Pkg; use strict; use warnings; use My::Schema; my $dbpath = 'C:/my/path/stats.db'; my $dsn = "dbi:SQLite:$dbpath"; my $schema = My::Schema->connect( $dsn, '', '', { RaiseError => 1, Aut +oCommit => 1 } );

When I try to run this script (on Windows) I get a popup saying "the Perl Cmd Line Interpreter encountered a problem and needs to close". There is no other output to STDOUT.

Any ideas?

Replies are listed 'Best First'.
Re: Cannot connect to a SQLite db using DBIx::Class
by metaperl (Curate) on Aug 24, 2009 at 10:33 UTC
    here is a script that writes a SQLite schema to disk.

    I ran it under Cygwin, but see no reason why it wouldnt work under Windows.

    If that script doesnt help, then ask in the DBIx::Class IRC channel - they will help you pronto.

Re: Cannot connect to a SQLite db using DBIx::Class
by parv (Vicar) on Aug 24, 2009 at 09:49 UTC
    Have you tried using PrintError set to a true value (in connect()), in the hope that the problem would be printed on the terminal (in which you run the program)?

      I didn't have that set initially (the docs state that it is on by default), but I just reran it after explicitly setting it to true. Still no output.

      Thanks for the suggestion. Any other ideas? I'm at a loss.

        I haven't used DBIx*. In DBI, there is $errstr ($foo = DBI->connect() or die $DBI::errstr) variable to get the error text; and, trace() (DBI->trace( $level = 2 ); additionally may pass a file path to store output) to see how things are progressing.

        I fear you would report that even after setting a trace level, nothing is printed. In that case, something might be closing|fiddling with, at least, standard error.