That's not a good solution for batch apps, mod_perl pages, daemons, and all sorts of other stuff. It's best to just configure the database to use something else, and to have it all work automagically. Most newer databases are cool enough to use other security mechanisms, making password just a step up from "security = totally off".