in reply to DBI / Mysql connections

Thanks for all the help.

Most of my experience is with PHP, and the default behaviour with Mysql under these circumstances is to reuse an existing process whenever possible. Perhaps the mysql driver with Perl behaves similarly. I guess the best thing for me to do is experiment further and work out what is going on behind the scenes. I'll look into the options mentioned and see what what suits.

regards

Cyril

Replies are listed 'Best First'.
Re^2: DBI / Mysql connections
by Anonymous Monk on Dec 03, 2004 at 15:32 UTC

    You can't really compare PHP with a Perl script.

    PHP is usually run via a webserver and more precise via a module of the webserver, which will re-use certains processes/threads.
    And only when something is re-used it can use an already made connection (so a script that is run via CGI can't re-use a connection made the previous time the page was loaded), using two connections from inside the same script would be possible but that isn't the default behaviour (or atleast not for a normal Perl script).

    If you would run perl via the apache module mod_perl and you have loaded Apache::DBI then the default would be to use the connect method of Apache::DBI which will try to use a previous created connection

Re^2: DBI / Mysql connections
by Errto (Vicar) on Dec 04, 2004 at 05:27 UTC
    If you are using Perl in a web application under mod_perl, then the answer is different: in that case, due to the beauty of a module called Apache::DBI, the connection will be cached automatically for you, even if you do not explicitly call connect_cached. If you look under the documentation for Apache::DBI you'll see the full explanation.