You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Plymouth Rock <Tr...@newmail.ru> on 2005/11/12 03:38:24 UTC

connection to PostgreSQL DataBase with Apache::DBI

 Hello.

 Before Apache::DBI installation I'd using just DBI & PgPP for
connecting with my PostgreSQL DataBase:

$user = "owner";
$password = "pwd";
$data_source = "dbi:PgPP:mypgdb;localhost;5432";
$dbh = DBI->connect($data_source, $user, $password);
$sth = $dbh->prepare( q{ SELECT ... FROM ... });
$rc = $sth->execute;

 Then I've installed Apache::DBI and modified my httpd.conf. In fact,
all the connections to DataBase from the same Perl-scripts became
persistent and now total script's work is faster excepting all its
initial runnings. For solving this I'd follow the example from the
mod_perl mans located here (Preopening DBI connections):
../Apache2/modperl/docs/1.0/guide/databases.html#Preopening_DBI_connections

  Apache::DBI->connect_on_init
  ("DBI:mysql:myDB:myserver",
   "username",
   "passwd",
   {
    PrintError => 1, # warn() on errors
    RaiseError => 0, # don't die on error
    AutoCommit => 1, # commit executes immediately
   }
  );

strings were added in the startup.pl and the

  "DBI:mysql:myDB:myserver"

string was modified to the

  "dbi:PgPP:mypgdb:localhost:5432"

 After server's restart it couldn't to start up actually. The
error.log said the following:

[Fri Nov 11 21:35:09 2005] [notice] Parent: Received restart signal --
Restarting the server.
[Fri Nov 11 21:35:09 2005] [notice] Child 1008: Exit event signaled. Child
process is ending.
[Fri Nov 11 21:35:10 2005] [notice] Child 1008: Released the start mutex
[Fri Nov 11 21:35:12 2005] [error] Can't load Perl file: C:/Program
Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
exiting...
[Fri Nov 11 21:35:12 2005] [notice] Child 1008: Waiting for 250 worker
threads to exit.
[Fri Nov 11 21:35:12 2005] [notice] Child 1008: All worker threads have
exited.
[Fri Nov 11 21:35:12 2005] [notice] Child 1008: Child process is exiting

 The server's name in the "[error]" string corresponds to the
ServerName's value of my httpd.conf.

 Is there a way to do the Preopening DBI connections just
for a PostgreSQL DataBase with Apache::DBI?

 Thanx.


Re: connection to PostgreSQL DataBase with Apache::DBI

Posted by Plymouth Rock <Tr...@newmail.ru>.
> > I tried to set PerlSetEnv/PerlPassEnv variables as described in the
guide.
> > It was difficult for me to do it properly as I did it for the first
time. I
> > even could set them incorrectly. Besides that, my mod_perl2 was
installed
> > and set up properly (it works excellently); but saying about Apache::DBI
> > module I should note that there isn't any mention about those variables
in
> > the corresponding man. Hence, it's most probably, those variables can
not be
> > a cause of my problem.
>
> The docs for Apache::DBI don't mention explicitly which
> environment variables to set, as this varies from database
> to database. Some databases may require certain environment
> variables to work; these may be visible in a cgi
> environment, but need the PerlSetEnv/PerlPassEnv directives
> in a mod_perl environment.
>
> To see if you do need such environment variables,
> try (without Apache::DBI) a mod_perl script or handler
> that connects to your database and does some simple
> operation. Does that work?
>
 Yes, it does. Yesterday I've described it in details in another
message with the
Subject:
"Re: Connection to PostgreSQL DataBase with Apache::DBI"
that addressed
To: Frank Wiles <fr...@wiles.org>
and
Copy: modperl@perl.apache.org <mo...@perl.apache.org>

Of course, I'd trying it without Apache:DBI installed as well as
without PerlSetEnv/PerlPassEnv set. It's probably, I'll be forced
to spend a few time to compose my bug report as described in
the mod_perl guide, but I'm not sure that it should be for this
Mailing List.


Re: connection to PostgreSQL DataBase with Apache::DBI

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Mon, 21 Nov 2005, Plymouth Rock wrote:

> I tried to set PerlSetEnv/PerlPassEnv variables as described in the guide.
> It was difficult for me to do it properly as I did it for the first time. I
> even could set them incorrectly. Besides that, my mod_perl2 was installed
> and set up properly (it works excellently); but saying about Apache::DBI
> module I should note that there isn't any mention about those variables in
> the corresponding man. Hence, it's most probably, those variables can not be
> a cause of my problem.

The docs for Apache::DBI don't mention explicitly which
environment variables to set, as this varies from database
to database. Some databases may require certain environment
variables to work; these may be visible in a cgi 
environment, but need the PerlSetEnv/PerlPassEnv directives
in a mod_perl environment.

To see if you do need such environment variables,
try (without Apache::DBI) a mod_perl script or handler
that connects to your database and does some simple
operation. Does that work?

-- 
best regards,
randy kobes

Re: connection to PostgreSQL DataBase with Apache::DBI

Posted by Plymouth Rock <Tr...@newmail.ru>.
 I tried to set PerlSetEnv/PerlPassEnv variables as described in the guide.
It was difficult for me to do it properly as I did it for the first time. I
even could set them incorrectly. Besides that, my mod_perl2 was installed
and set up properly (it works excellently); but saying about Apache::DBI
module I should note that there isn't any mention about those variables in
the corresponding man. Hence, it's most probably, those variables can not be
a cause of my problem.

> > Before Apache::DBI installation I'd using just DBI & PgPP for
> > connecting with my PostgreSQL DataBase:
> [ ... ]
> > After server's restart it couldn't to start up actually. The
> > error.log said the following:
> [ ... ]
> > [Fri Nov 11 21:35:12 2005] [error] Can't load Perl file: C:/Program
> > Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
> > exiting...
>
> Assuming that everything works OK outside of a mod_perl
> environment, it may be that your databse needs certain
> environment variables set. If so, try setting these
> using PerlSetEnv or PerlPassEnv:
>
http://perl.apache.org/docs/1.0/guide/config.html#PerlSetEnv_and_PerlPassEnv
>


Re: connection to PostgreSQL DataBase with Apache::DBI

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Sat, 12 Nov 2005, Plymouth Rock wrote:

> Before Apache::DBI installation I'd using just DBI & PgPP for
> connecting with my PostgreSQL DataBase:
[ ... ]
> After server's restart it couldn't to start up actually. The
> error.log said the following:
[ ... ]
> [Fri Nov 11 21:35:12 2005] [error] Can't load Perl file: C:/Program
> Files/Apache Group/Apache2/conf/startup.pl for server localhost:80,
> exiting...

Assuming that everything works OK outside of a mod_perl
environment, it may be that your databse needs certain
environment variables set. If so, try setting these
using PerlSetEnv or PerlPassEnv:
  http://perl.apache.org/docs/1.0/guide/config.html#PerlSetEnv_and_PerlPassEnv

-- 
best regards,
randy kobes