[jump to content][No Software Patents]Tools (new) : sq [ Home | Scylla+Charybdis old home | Tools (old) | Tools (new) | FAQ | Downloads ]

Scylla and Charybdis sq - Tools

The tools are developed under Linux with ESR's paradigm release early, release often in mind.
So you can consider this beta software, or alpha, or pre-alpha, or even worse ;)

Have a look in the download directory for all downloads.
As always here, all you get is the source. No binaries here.

sq 0.2.1-20080607-015649

SQLITE3 query tool for shell usage (look into latest version, download latest version 0.2.1-20080607-015649, sig)

Sorry, only works with sqlite version 3 yet!

If you want to pipe data in and out a sqlite3 database from shell, this tool is for you. With this tool you never have to escape arguments from shell ever again (as long as you don't pass them in the SQL string directly).

Example insert:

export env="this goes into col1"
arg="this goes into col2"
./sq3 test.db 'create table a ( col1, col2, col3 ); insert into a values ($env,?,:fd3)' "$arg" 3< filename
This stores the environment variable $env into col1, puts the arg into col2 and reads col3 from filename as BLOB.

Reading the data is likewise easy:

./sq3 test.db 'select col1,col2,col3 from a' |
while read -r row col type data
do
case "$type" in
t)      echo "row=$row col=$col data=$data";;
e)      echo -e "row=$row col=$col data=$data";;
0)      echo "row=$row col=$col NULL";;
esac
done
Data which cannot be read easily is escaped using the shell escape.

Another usage for access of attachment or binary data:

./sq3 test.db "insert into a values ('file',NULL,:fd0)" < file
./sq3 -r test.db "select col3 from a where col1='file'" | cmp - file

Or lazy argument processing:

./sq3 test.db "delete from a; insert into a values ('line1','line2','line3'); insert into a values ('lineA','lineB','lineC')"
./sq3 -r test.db "select * from a" |
{
while read -r col1 && read -r col2
do
read -r col3 || echo -n "last "
echo "lazy: $col1 - $col2 - $col3"
done
}
The funny thing is the missing newline which makes the "read -r col3" to return EOF. Well, one can consider this a feature, but it's moreover a crude sideeffect ;)

History:

version 0.2.1-20080607-015649

download (14492 bytes) sig

Bugfix release, echo -e sequence still was bugged

The problem is:

echo '\\0041' | { read a; echo -e "$a"; }

vs.

echo '\0041' | { read -r a; echo -e "$a"; }

I prefer the latter, but tested the first one. SIGH.

version 0.2.0-20080530-025748

(14348 bytes archive)

Bugfix release, echo -e sequence was bugged

Option -a and -z added

version 0.1.1-20080304-103430

download (14057 bytes) sig

:fd# did no more work, it only worked in form :fd#_ which worked only with switch -l.

Both has been fixed. :fd#_ form now works in all aspects, and :fd# now works again.

version 0.1.0-20080207-033123

(14136 bytes archive)

Minor bugfix removed (argv[0] for CygWin), option -l for looping added

With Option -l you can do things like

find . -type f -print0 |
md5chk -nz |
sq3 DB 'insert into md5table ( md5, name ) values ( :fd0__32, :fd0__0 )'

For LF use something like ":fd0__10".

To get rid of a CR in a CR LF sequence, use the trim option. This is activated by a 't' like ':fd0_100t' or ':fd0_t_10'.

But be careful as always, this has not yet been extensively debugged.

version 0.0.0-20060602-033245

download (12709 bytes)

It works

License and Disclaimer

All you can see here is free software according to the GNU GPL.
Copyright (C)2000-2008 by Valentin Hilbig
Note that the software comes with absolutely no warranty of any kind.
You use the software at your own risk.
Valentin Hilbig cannot be hold responsible for any unintended damage,
lost data or malfunction of the software you can find here.

[FSFE contributor 2007]

[end of page - jump back to content][hacker culture]
Last modified: 2008-12-27 by Valentin Hilbig [ Imprint / Impressum ]