|
Project Information
|
Allows you to pipe to or directly use sql with flat data files. Great for log parsing or adhoc temporary sql parsing. Supports joins, insert, delete, update, primary key, subqueries, regular expression comparisons etc. AWK is an incredibly powerful tool - but it can be pretty unmaintainable/hard to juggle columns when referencing them by number / order instead of name. So AQL allows you to access your data as if it were an sql table. The idea is to leverage AWK - not replace it. AQL is mereley a perl script which parses sql and applies it either to the files in the from clause or the data piped to the script. There are a few ways of using it. By default it uses the pipe as the field seperator but that can be set by -s flag OR env var AQL_FIELD_SEP. Obviously it expects the first row to be the header/column row. Or you can specify this with the fields keyword. Here are some simple examples (un-necessary use of cat is to illustrate piping). #when passing data to stdin via pipe you can do implicit [select] * [from] [where]
cat user_access.log | aql user_level eq admin and page in page1 page3 page6
#here is an example of accessing a file directly - note use of optional comma
aql select user, level from user_access.log where level gt 20 and admin eq true
#simple join using actual .tbl files
aql select user, name, age
from users, special_users
where users.id eq special_users.user_id
and special_users.level eq high_level
#using aql to pipe filter aql - first aql uses implicit $0 clause (any field/column)
cat dates.log | aql eq '10/10/2009' | aql type eq important and status eq pending
|