Most of the mod_perl specific DBI issues I've heard about have to do with things being set up more than once, since they are not automatically re-initialized each time through. It seems like an odd problem to be having that you can't connect at all when running under mod_perl. My first guess is that some other part of the script is having trouble because it's variables are not properly initialized.. It's hard to tell though without seeing the relevant parts of your module.

Look at the input to the DBI functions, see if there are variables there that could be causing the problem, and do sanity checks by logging or debugging to screen to make sure the parameters are what you expect them to be.

Also, you say your script works from the command line - is it exactly the same script you are running from mod_perl? Usually you'd at least have to be doing a '-e handler' from the command line to make that work, and simulate the apache request obj and the rest of the mod_perl interface. Perhaps your module isn't fully adapted to work in mod_perl? What command line do you use?

Another thought. If you know it works through the command line, as a half-way measure, try just calling the script through the shell with backticks or system(). At least you'll have more context on when your database connection works and when it doesn't.

It's hard to give a better response without some code to look at.


In reply to Re: mod_perl 2 DBI problem by dynamo
in thread mod_perl 2 DBI problem by imcsk8

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.