in reply to TexQL - SQL queries on text files

Minor nit:
cat some_random_file | texql.pl -s /:/ select c0 from t where c1 = 0
That's a useless use of cat.

Were you aware that DBD::AnyData already does a lot of this?

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: TexQL - SQL queries on text files
by jplindstrom (Monsignor) on Mar 29, 2004 at 17:52 UTC
    If I understand it correctly, DBD::AnyData provides SQL access to a number of specific formats.

    What I find useful with TexQL is the ability to specify the format of the text at use-time. So it's basically a usable front-end to a parser/loader for SQLite.

    Could you please elaborate a bit on in what way I could have used/reused DBD::AnyData to do this?

      Your program could easily be re-written as a front-end to DBD::AnyData which would allow it to operate on FixedLength, XML, CSV (with any record and field separators, with alternate delimiters and escape characters, etc), and many other formats. This would not only allow you to use many other input formats, but you could also have an output flag that would allow you to dump the results to any of those formats or to any DBI database, not limited to SQLite as yours is. If all the user wants is the results of the query, with DBD::AnyData as a backend, everything would happen in memory without creating an intermediate database on disk as your script does.

      If you want to submit a patch, I'd be glad to include it (with credit natch) in DBD::AnyData (I'm its author), or it could be a standalone. Either way, holler if you need AnyData to do something it doesn't currently.

Re: •Re: TexQL - SQL queries on text files
by eserte (Deacon) on Mar 29, 2004 at 14:01 UTC
    That's a useless use of cat.

    This might be true if you're tight on CPU cycles. But in the evaluation process of the "correct" cmdline, I often exchange another filter with just "cat" for a quick check. You could argue that I could use "< some_random_file" instead, but on the beginning of a command line it's likely that I use the wrong angle bracket :-/ (It is far less likely on the end of a command line)