SQLite Forum

How to dump a table to a TSV file but escape characters properly
Login
Another way is to write a SQLite extension function which will produce the format that you need, and then you can write e.g. `select formatted(a,b,c,d) from mytable;` or whatever you require.