in reply to Get From DB

A few points:
- Everybody in this monastery should tell you that you should use strict and warnings.
- If that "$CGI-DIR" means anything serious, you should also have Taint checking. If it doesn't (as I strongly suspect and "-w" could have told you), what is it doing there?
- Using DBI, you should either checking for an error after "connect", or set {RaiseError => 1}.
- data in a datbase is seldom reduced to a single table. And even if it is, getting data from a table without a "WHERE" clause, can fetch you a million records for no sensible reason.
- I fail to see the logic behind assigning $a =$#row and then incrementing it. How about
while (my @row=fetchrow_array()) { print join ",", @row; print "\n"; }
- what is the point in clearing the screen, if you are sending the output to a file?
- "seperate" should be spelled "separate"
- you are assuming that the user knows SQL, since (s)he is supposed to enter special options. What is the purpose of using this "utility" if I can do the same with an one-liner?
$ mysql -t -u user -p -e "SELECT blah,Blablah from my_table" I could continue, but I think it's enough.
gmax

Replies are listed 'Best First'.
Re: Re: Get From DB
by vladb (Vicar) on Dec 19, 2001 at 21:45 UTC
    Or for that matter, I could use these commands in Emacs
    M-x sql-oracle

    OR
    M-x sql-mysql

    to connect to any database and do any number of SQL queries my soul desires. Also, the advantage of using Emacs (or XEmacs! ;) is that you have a buffer where all your SQL may be saved to and retreaved for later use. Editing is also a snap.


    "There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith