SELECT is an SQL interface to text files.

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!
send us
an update
GPL v3 
3.7/5 13
Markus Bertheau
ROOT \ System \ Logging
1 SELECT Screenshot:
SELECT is an SQL interface to text files:

$ SELECT response_code, count(1) FROM access_log WHERE method = "'GET'"
> GROUP BY response_code ORDER BY 2 DESC

response_code | count(1)
200 | 157820
404 | 25138
304 | 17938
301 | 2348
302 | 1486
206 | 673
405 | 16
401 | 15
500 | 8
403 | 1
$ head -1 access_log - - [23/Sep/2007:22:42:04 +0200] "GET / HTTP/1.1" 200
768 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20061201 Fir
efox/ (Ubuntu-feisty)"

SELECT currently specificially supports the NCSA extended/combined transfer log format (access_log), and all other text files generically. It is easily extensible to support other text file formats.

SELECT is licensed under the GPL Version 3.


SELECT requires Python and pysqlite2. Python 2.5 includes pysqlite2.

Download and unpack the tarball and copy SELECT to a directory in your $PATH, for example /usr/local/bin:

$ wget
$ tar xfj SELECT-0.1.tar.bz2
$ sudo cp SELECT-0.1/SELECT /usr/local/bin


SELECT [fieldlist] FROM file [rest_sql]

fieldlist is a comma separated list of field names or the special keyword all, which is replaced by a star *. file is a file name or - to read from standard input. rest_sql may contain SQL clauses like WHERE, GROUP BY, HAVING, LIMIT, OFFSET and ORDER BY.

How it works

SELECT at first tries to determine a file type a set of regular expressions. If that succeeds, speaking column names are available, and the lines are split into columns according to their semantics. If it didn't, they are named with numbers and split by white space. Then SELECT loads the data into an in-memory SQLite database, executes the query and outputs the results to stdout.

Last updated on March 13th, 2008

#SQL interface #SQL queries #SQLite database #SQL #interface #queries #database

Add your review!