[sqlite] attempt at output with thousands separator via extension

2015-11-23 Thread Mohit Sindhwani
On 23/11/2015 11:32 AM, Rowan Worth wrote: > Hi Bruce, > > I had a go at post-processing the sqlite3 shell's output to apply thousand > separators. I don't recommend looking too hard at the sed for the sake of > your sanity, but the gist is it repeatedly prepends a comma to trailing > groups of

[sqlite] attempt at output with thousands separator via extension

2015-11-23 Thread Stephan Beal
On Mon, Nov 23, 2015 at 1:57 PM, Bruce Hohl wrote: > www.sqlite.org/loadext.html states that: "Loadable extensions are C-code." > Can someone confirm this please. > pedantically speaking: the _entry point_ for the extension is C. The implementation may be in any language. > If I figure out

[sqlite] attempt at output with thousands separator via extension

2015-11-23 Thread Simon Slavin
On 23 Nov 2015, at 1:02pm, Stephan Beal wrote: > On Mon, Nov 23, 2015 at 1:57 PM, Bruce Hohl wrote: > >> www.sqlite.org/loadext.html states that: "Loadable extensions are C-code." >> Can someone confirm this please. > > pedantically speaking: the _entry point_ for the extension is C. The >

[sqlite] attempt at output with thousands separator via extension

2015-11-23 Thread Rowan Worth
Hi Bruce, I had a go at post-processing the sqlite3 shell's output to apply thousand separators. I don't recommend looking too hard at the sed for the sake of your sanity, but the gist is it repeatedly prepends a comma to trailing groups of three digits, and then repeatedly removes commas which

[sqlite] attempt at output with thousands separator via extension

2015-11-23 Thread Dominique Devienne
On Sun, Nov 22, 2015 at 8:14 PM, Simon Slavin wrote: > Of course that too is unlikely to happen, this time for > backward-compatibility reasons. Maybe it could be a consideration of > SQLite4. > Why keep bringing up SQLite4? AFAIK, SQLite4 has been inactive for a long time, and not much of a

[sqlite] attempt at output with thousands separator via extension

2015-11-23 Thread Simon Slavin
On 23 Nov 2015, at 7:56am, Simon Slavin wrote: > On 23 Nov 2015, at 7:41am, Dominique Devienne wrote: > >> Why keep bringing up SQLite4? AFAIK, SQLite4 has been inactive for a long >> time, and not much of a response anytime someone asks about it. > > It's a way of telling people who ask for

[sqlite] attempt at output with thousands separator via extension

2015-11-23 Thread Bruce Hohl
Gentlemen, thanks all for your comments. Before I posted I knew the thousands separator was problematic for the reasons stated by Simon. I figured it was intentionally left out of sqlite's printf(). I wanted to make sure I was not missing a known or easy solution. As sqweek/Mohit suggested I

[sqlite] attempt at output with thousands separator via extension

2015-11-23 Thread Simon Slavin
On 23 Nov 2015, at 7:41am, Dominique Devienne wrote: > On Sun, Nov 22, 2015 at 8:14 PM, Simon Slavin wrote: > >> Of course that too is unlikely to happen, this time for >> backward-compatibility reasons. Maybe it could be a consideration of >> SQLite4. > > Why keep bringing up SQLite4?

[sqlite] attempt at output with thousands separator via extension

2015-11-22 Thread Simon Slavin
On 22 Nov 2015, at 6:18pm, Scott Robison wrote: > All technically correct (except the implication that a thousands separator > format is standard, as it is not). But the OP wants to be able to do > formatting from within SQL as he is using the SQLite shell, thus there is > no programming

[sqlite] attempt at output with thousands separator via extension

2015-11-22 Thread Simon Slavin
On 22 Nov 2015, at 3:34pm, Bruce Hohl wrote: > printf > support for a thousands separator would be nice One problem with thousand separators is that different countries use different characters for them. There's an unholy mix of commas, spaces, dots and apostrophes out there, not to mention

[sqlite] attempt at output with thousands separator via extension

2015-11-22 Thread Richard Hipp
On 11/22/15, Bruce Hohl wrote: > Within sqlite3.c there are ~1000 lines of printf.c code > (added in 3.8.3) so it does seem to be a development matter. Let me clarify that: The printf.c file has been part of SQLite since the beginning - over 15 years. The SQL "printf()" function was added in

[sqlite] attempt at output with thousands separator via extension

2015-11-22 Thread Scott Robison
On Sun, Nov 22, 2015 at 10:34 AM, Simon Slavin wrote: > > On 22 Nov 2015, at 3:34pm, Bruce Hohl wrote: > > > printf > > support for a thousands separator would be nice > > One problem with thousand separators is that different countries use > different characters for them. There's an unholy

[sqlite] attempt at output with thousands separator via extension

2015-11-22 Thread Bruce Hohl
Thanks for those comments, I now understand better what is being returned. It seems an easy work around for shell output with thousands separator may not be possible. Within sqlite3.c there are ~1000 lines of printf.c code (added in 3.8.3) so it does seem to be a development matter. printf

[sqlite] attempt at output with thousands separator via extension

2015-11-21 Thread Bruce Hohl
(1) SQLite will not return output with a thousands separator as follows: sqlite> select printf("%15.2f",123456789.12789); 123456789.13 sqlite> select printf("%'15.2f",123456789.12789); (2) C language

[sqlite] attempt at output with thousands separator via extension

2015-11-21 Thread Scott Robison
On Sat, Nov 21, 2015 at 1:47 PM, Bruce Hohl wrote: > (1) SQLite will not return output with a thousands separator as follows: > > sqlite> select printf("%15.2f",123456789.12789); >123456789.13 > > sqlite> select printf("%'15.2f",123456789.12789); > > > >