in reply to can one create a "session" of Perl & Mysql?

First as a suggestion, you might want to look at this node: What are placeholders in DBI, and why would I want to use them?. While your code as written does work, the prepare statements can be somewhat "expensive". By using place holders, you can prepare the statement(s) once and then execute them with different values. The table name can't be a variable because a prepare is a table specific execution strategy.

If you want to save the credentials for a future run of your script, you will have to have some mechanism for persistence of this data, perhaps in some table in different SQL master account? There are various security issues with this and of course you would have to handle the case where the user changes their credentials unbeknownst to your script. Perhaps other Monks have ideas on this. You could also leave your script running so the user could just keep it open in a window with a prompt for the next set of user values (without having to enter the login stuff again). I wanted to mention the place holder idea so that you can move some code out of the loop.

Update: still working on my morning coffee... Now that I re-consider this, I would re-organize the loop such that you can keep the script running in a separate window. User would exit by typing "quit", closing that window or whatever. This is an extra step for a single query, but easier for multiple queries and avoids complications with persistent storage of important security information.

  • Comment on Re: can one create a "session" of Perl & Mysql?