Perl Programming Help:
Passwords in code
Sep 29, 2005, 6:50 PM
MySQL seems to be set up and I am starting to notice that you have to put your real passwords in the code! Is there a way around this? I suppose I could use a very simple algorithm to make the passwords not obvious to the naked eye...I just don't like seeing them right there. Also, can someone offer me some basic suggestions about how to interface with the database? What I mean is should I use a sub routine to connect or just repeat the line every time I need to edit the database. Plus, should I use a different username and password for each table? Also, is one database ok for an entire site? My new site is based on the database collaboration and this will have many tables for the same site, is this good? Is there any benefit to having separate databases for the same site?
Is there a very comprehensive and quick guide to commands that I can refer to? I like reading text to get started and I have found two great resources online that have brought me up to above-beginner level in about 2 hours of study. Now, I just want a simple guide that lists all the commands that you can use with a quick summary, instead of a whole page for each command with examples and other extra unnecessary materials.
Thanks for all your great help everyone!
Visit my new site devoted to reviewing the latest pocketpc products and news that I built in cgi-perl!
Sep 30, 2005, 3:50 AM
Store your usernames and passwords in a config file and read that file at the start of your program.
Re: [benn600] Passwords in code
Create a connection as when your program needs to connect to the database and reuse that connection for as long as the program is running. Class::DBI hides all of this from you.
It's usually a good idea to have different usernames for different roles. For example, have a read-only user which you can use for programs that only need to read the database and a a read/write user for programs that need to update it. Maybe even make it more granualar than that and have different read/write users that have write access to different sets of tables in the database.
I generally have one database per "system". Each database usually has multiple tables.
MySQL Pocket Reference looks like a good quck summary. You might also like MySQL in a Nutshell or SQL in a Nutshell.
Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks