Using -line Option I get this output from SQLite:row1_column1 = valueArow1_column2 = valueBrow2_column1 = valueCrow2_column2 = valueDSo one line for each column value and result rows are separated by a blank line. I need to get this output in a array or list containingvalueA,valueBvalueC,valueDAdditionally non-numeric (!) values shall be enclosed by ' and '. Any simple way to do this? Thanks for any hint!
Parsing SQLite output
shell script;scripting;sqlite
The following awk script does what you want, and even escapes quotes in strings:BEGIN   { RS=\n\n          FS=\n        }function field(s){        sub(/^[^=]*= /, , s)        if (match(s, /^[-][0-9]+$/) == 0) {                gsub(/'/, '', s)                s = ' s '        }        return s}        { print field($1) , field($2) }(The numeric regular expression does not handle floating-point values.)But the simplest way to do this does not use -line but SQLite's built-in SQL quoting:sqlite3 -separator , -list my.db 'select quote(col1),quote(col2) from mytab;'