Maybe it is just me, but I look at perl code with SQL queries in it and cringe. I don't know what it is about them, maybe just the raw "not perl" look they have.
In some recent projects, I've attemped to modulize all my mySQL calls. I would avoid direct queries at all costs. I'd make up weird subs and stuck them in a "SQL" package so they would not muck up my real perl code.
So sitting back, looking at all of this from the distance, I've come to the conclusion that there are two possible conclusions:
DBI is tremendously powerful and cannot be leashed.or
DBI could be effectively "leashed", or at least the more simplistic usage.
Now maybe I'm crazy (and if so, please tell me and I'll just keep telling myself that SQL queries in perl code is not a bad thing.) I am no DBI Power User, as you can probably tell, so this is a shot in the dark for me: I really do not know what kind of response to expect.
It call comes down the question of Is it feasable to write a reusable module that controls DBI? Is there something similar that has been already written that I have missed?
Just off the top of my head, an example interface (quasi-code):
$db = connect(HOST => $host, PASSWORD => $pass, ..); $result = $db->select(TABLE => $table_name, FIELDS => ["one","two","th +ree"],ORDERBY => "two",DESCENDING => 1); print $result->[0]->{"one"};
Again, thats quasi-code, just an example of what I'm thinking of for an "interface." Personally, I would love that sort interface, and I would assume others would too .. ? Would a module like this be worth throwing together for personal use, or am I moron for not already knowing about something similar to this? Or should I suck it up and leave my raw queries in my code? :-D
I'd appreciate any feedback. Thanks.
-billyak
In reply to Leashing DBI by billyak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |