Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Simon (89)

Simon
  simon-use-perl@perlhacker.org
AOL IM: lathosjp (Add Buddy, Send Message)

Busy Man.

Journal of Simon (89)

Thursday April 25, 2002
01:51 PM

Squalk!

[ #4464 ]
At work, I'm hacking on a courses database. We use AxKit to generate course information pages, searches, bookings, etc., all back-ended by a simple OO library I've written and ultimately an SQL database. Very cool, all perfectly buzzword-friendly.

Unfortunately, the data is currently in all sorts of places, and the best way to get it to me as in several flat text files. So once I think I've got everything sorted, someone comes along and says "Can you add this list of descriptions to the database?" and provides me a text file linking course codes to descriptions. I had been writing a series of little hacks to parse the file and insert the data into the database, and then I thought "Why not solve the general case?" The result is squalk. ("SQL awk") It's not very awk-like, but it lets you do things like this:

squalk -F: -d courses -e 'update courses set category=$2 where code=$1'

That's to say, connect to the courses database, then rip through the text file splitting on :, setting the category to be the second field where you match course codes in the first.

Neat, eh? It's on CPAN; the version there doesn't support transactions but the one on my hard disk does, so there.

(Of course, then my cow-orkers pointed out that this doesn't buy you much more than awk -F: '{print "update courses set ..."}' | psql courses. Ah well. It was fun while it lasted.)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.