Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Cannot connect to a SQLite db using DBIx::Class

by bobf (Monsignor)
on Aug 24, 2009 at 04:33 UTC ( [id://790727]=perlquestion: print w/replies, xml ) Need Help??

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 Schema.pm 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 (Parson) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://790727]
Approved by targetsmart
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-19 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found