Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: [DBIx::Class] Can I extract $dbhandle from schema?

by LTjake (Prior)
on Aug 21, 2007 at 11:04 UTC ( #634053=note: print w/ replies, xml ) Need Help??


in reply to [DBIx::Class] Can I extract $dbhandle from schema?

I belive you can access the $dbh via the Storage class:

my $dbh = $self->schema->storage->dbh;

--
"Go up to the next female stranger you see and tell her that her "body is a wonderland."
My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
" (src)


Comment on Re: [DBIx::Class] Can I extract $dbhandle from schema?
Select or Download Code
Re^2: [DBIx::Class] Can I extract $dbhandle from schema?
by dreel (Sexton) on Aug 21, 2007 at 12:41 UTC
    Great! 10x! It's working! DBIx creates connection at every query? Or it uses sheared dbhandle? May be you read it before me )
      DBIx::Class re-uses existing connections. It checks if connections are still open: if so they are re-used otherwise it reconnects.

      Please note DBIx::Class is not sharing connections: every my $schema = My::DB->connect('dbi:mysql:DB', 'user', 'secret_password'); will remain separate from every other connection, but every query within an individual $schema will re-use the same connection as long as it is still open. Connections only get closed when the script finishes or when explicitly closed ($schema->disconnect;) or when timed-out server-side.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        I am using DBIx::Class and when I look at the processlist (mysql) all the connections are in state of sleep. I am using mod_perl so the scripts should be staying alive. Is it recommended to call disconnect each time or to try and re-use the existing connection?
        Sorry, thought I was logged in. This applies to the post above. I also tried using Apache::DBI and it didn't seem to work and I have since read this is not recommended either. Is that not a good solution?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://634053]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-12-20 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (96 votes), past polls