SQLite Forum

Support for Markdown formatted table output from a query
Login
Of course there are other formats that may be wanted, although in many cases it can be done using SQL functions provided by extensions, but in some cases (such as the cases you listed here) cannot so easily be done with extension functions, so is good to add them as built-in formats, I suppose.

One case where an extension function could do is PostScript format (so it probably should not be built-in (especially considering that most users probably will not be programming in PostScript anyways), although it is possible that the user will want to customize which extensions are available by default in the command shell before compiling it, especially to implement a custom VFS; this would probably be a good idea, I think). It could be represented as a sequence of procedure tokens (one procedure per row), for example, one row could be: `{//null 32 -5.6 (Hello \(\(| \n) <B2A700010000>}` A null should be `//null` (the two slashes indicate to retrieve the value that the name refers to and enter that, rather than entering the name itself); the next two items are an integer and a floating number, and then a string, and then a blob. A string in PostScript is in parentheses; backslashes and unbalanced parentheses inside must be escaped, and the C escapes `\b`, `\t`, `\n`, `\f`, and `\r` are also supported, and other bytes are using octal escapes with three digits. The next one is a hex blob; in PostScript it is actually just another syntax for a string, and is treated in the same way (and PostScript strings are limited to 65535 bytes, although I think recent versions of Ghostscript increase this limit). A PostScript program could then load a file (or use `%pipe%` to execute SQLite and read the rows that way) and then use the `token` operator to extract each row; or something like `[(filename.ps) run]` could be used to load all of it into a single array at once. (If I need this, then I would probably write such an extension.)

In both JSON and PostScript though, there are limits to numbers; they can't represent all 64-bit integers. PostScript supports 32-bit integers and 32-bit floating point; JSON supports only 64-bit floating point. JavaScript does have big integers now (denoted by writing `n` at the end of the number), but this is not possible with JSON.

That is just one example; of course, there are many other possibilities too, and which ones are useful depend on your use of them, I suppose.

I do not know the answer of your first three questions, but for the fourth question, I should expect yes (at least by default; you may have an option to disable it), since otherwise it won't work. But, not using a lot of Markdown stuff, I wouldn't really know; perhaps someone else on here knows better than I do.