[Tutor] Including files for security.
Kent Johnson
kent37 at tds.net
Sun Aug 24 19:24:55 CEST 2008
On Sun, Aug 24, 2008 at 12:08 PM, Dotan Cohen <dotancohen at gmail.com> wrote:
> I have a specific file in the web tree that makes a database call. I
> am uncomfortable keeping the database username and password in the
> file. In PHP I usually put the database connection data in a file
> outside the web tree and use the include (http://il.php.net/include/)
> function to get the data. Is there a similar mechanism in Python? What
> do other Python programmers use?
You can use the normal file open() and read() functions to read the
username and password from a file. You can write the file as a Python
module, put it somewhere in the Python path and import it. You can use
the ConfigParser module to read an INI file...
Kent
More information about the Tutor
mailing list