tabview as alternative

This commit is contained in:
Ville Rantanen
2021-03-24 21:00:41 +02:00
parent 92c72edd02
commit 72310083f6

View File

@@ -8,6 +8,8 @@ echo 'Sqlite3NCSV: view sqlite3 DB with ncsv.
TABLE: If not given, first in schema used. TABLE: If not given, first in schema used.
QUERY: If the second argument contains spaces, it is assumed to be a query. QUERY: If the second argument contains spaces, it is assumed to be a query.
-l: List table names -l: List table names
note: will try for tabview if ncsv not installed
' '
} }
[[ "$1" == "-h" ]] && { [[ "$1" == "-h" ]] && {
@@ -33,6 +35,11 @@ sqlfile="$1"
} || { } || {
query="$table" query="$table"
} }
VIEWER=ncsv
which ncsv > /dev/null || {
VIEWER="tabview -"
which tabview > /dev/null || VIEWER="cat -"
}
sqlite3 -header -separator ' ' -nullvalue NA "$sqlfile" "$query" | ncsv sqlite3 -header -separator ' ' -nullvalue NA "$sqlfile" "$query" | $VIEWER