[grand-rapids-pm-list] Environment Variables and/or Properties

Sean McMillan Sean.McMillan at priorityhealth.com
Mon Jul 23 12:20:48 PDT 2007


> You are working on a program with variables whose values
> depend on the environment that you are in.  For example, the
> database connection, dsn, user id, password.  When you are in
> the development environment, you want to connect to the dev
> database with development credentials.  When you are in
> test...test and prod....prod.  In what ways are you
> specifying these different values in each environment?  What
> has worked best for you?

        So, in the past, what I've done is create a perl module (.pm) that connected to the database and made the $dbh variable available globally. I checked the hostname (I believe that's $ENV{hostname}, but double check before you use it,) and if it was in a list of production boxes, I connected to the production database. Otherwise, I connected to my development database. That meant that I needed to modify Connection.pm when they added a new production host. I also set some other useful variables, like email server name and person to contact on error.

        This was on Oracle, which allows you to have multiple simultaneous statements. SQL Server only allows one statement at a time, so I wrote a function that would return a new $dbh in case you needed more than one. It was also a web interface under CGI, not mod_perl, so the handles were not shared between script instances.

        Where I work now, we have a standard DB Connect module which does approximately the same thing, but also looks up passwords for you. That way developers don't have access to the production passwords, so we can pass our audits. I don't think there's much more underneath it though.

        --Sean

** ** **  PRIVILEGED AND CONFIDENTIAL  ** ** **
This email transmission contains privileged and confidential information intended only for the use of the individual or entity named above.  Any unauthorized review, use, disclosure or distribution is prohibited and may be a violation of law.  If you are not the intended recipient or a person responsible for delivering this message to an intended recipient, please delete the email and immediately notify the sender via the email return address or mailto:postmaster at priorityhealth.com.  Thank you.

- end -



More information about the grand-rapids-pm-list mailing list