Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.
Quick
- ($a, $b....) = unpack("A2A7...", $packed)
- push( array, list )
Saturday, December 22, 2012
sqlite output formats
I hadn't previously noticed that sqlite has output formats other than line and column. In particular there are also the csv and tcl modes.
The difference between csv and tcl modes appears to be that in tcl all items are quoted, and newline is represented as \n, whereas in csv mode items are not always quoted and newline is represented as a newline.
I can't work out the exact rules it uses for quoting in csv mode, it appears to be that an item is quoted if it contains a newline or a separator, and sometimes even if it doesn't contain either of those.
Unfortunately, it doesn't seem possible to tcl mode from the command line, even if you use a script to construct a multi-line command line with the .mode tcl separated from the SQL by a newline. This makes them considerably less useful.
You can however specify -csv on the command line (contrary to my previous assertion). You have to be prepared to parse fields with an embedded newline, but it can be done.