cpython icon indicating copy to clipboard operation
cpython copied to clipboard

Colorize sqlite3 CLI

Open StanFromIreland opened this issue 6 months ago • 13 comments

Feature or enhancement

Proposal:

I will open a pr once https://github.com/python/cpython/pull/133393 is complete.

General idea is to follow repl color scheme:

sqlite>: repl magenta (i.e. >>>) keywords: repl keyword blue (i.e. def) .quit/.help: repl turquoise (i.e. exit) rest: no color

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-133461

  • gh-135224
  • gh-136079

StanFromIreland avatar May 05 '25 15:05 StanFromIreland

See also theming support, which will hopefully be merged soon: issue https://github.com/python/cpython/issues/133346 / PR https://github.com/python/cpython/pull/133347.

hugovk avatar May 05 '25 15:05 hugovk

I like how Stan is already talking in terms of semantic classes.

ambv avatar May 05 '25 15:05 ambv

Unfortunately the code currently uses a subclass of InteractiveConsole (color support anytime soon? ;-) so I would have to write a raw_input, but that still has to wait for the other pr ideally.

For now I will open a pr adding color to the line starts as it is not depending on the pr. (Progressing like pyrepl coloring...)

StanFromIreland avatar May 05 '25 17:05 StanFromIreland

This is not in the sqlite3 project.

cc @ezio-melotti Can the project be set up to add them when the label is used topic-sqlite3, it would be a good test for the github workflow-like automations for projects that we discussed earlier?

StanFromIreland avatar May 09 '25 16:05 StanFromIreland

Done!

Details I enabled the auto-add workflow:

Image

which matches 7 issues -- including this one -- but doesn't add them unless they are updated or newly created:

Image

Note: after enabling the workflow and posting this message, the issue wasn't added to the workflow, so I added it manually. The GitHub docs are not clear on what "updated" means (apparently posting a message doesn't count as an update).

Note: I initially added in:title to the auto-add workflow query, but I got an error stating that it's invalid. Even after removing it, the query matches 7 issues, even though when I follow the "See 7 existing issues" link I get 50 issues. I now reported this issue to GitHub.

ezio-melotti avatar May 10 '25 04:05 ezio-melotti

posting this message, the issue wasn't added to the workflow

That is odd, maybe it only checks on title modifications?

I initially added in:title to the auto-add workflow query, but I got an error stating that it's invalid.

We could add on the label addition instead like other projects.

StanFromIreland avatar May 10 '25 07:05 StanFromIreland

We could add on the label addition instead like other projects.

Done, and it seems it work on label addition (tested on #129926).

Image

ezio-melotti avatar May 10 '25 11:05 ezio-melotti

The new sqlite CLI allows spaces between a dot and the command:

sqlite> . quit

I don't think that was an intentional change?

encukou avatar Jun 13 '25 16:06 encukou

I don't think that was an intentional change?

I believe @serhiy-storchaka merged the change that opened up allowing this.

erlend-aasland avatar Jun 13 '25 16:06 erlend-aasland

For reference, the issue: https://github.com/python/cpython/issues/133439, the commit: https://github.com/python/cpython/commit/ebd4881db2e8448b238d8ca2f6fcf331826132dd

It also has several other errors, like no spacing between words in the error message. (I have a pr to fix these: https://github.com/python/cpython/pull/133807/)

StanFromIreland avatar Jun 13 '25 16:06 StanFromIreland

I don't think that was an intentional change?

It was intentional. The SQLite CLI allows this.

serhiy-storchaka avatar Jun 13 '25 17:06 serhiy-storchaka

Thank you for the fix! Is there anything more to do for this issue?

encukou avatar Jun 26 '25 12:06 encukou

Is there anything more to do for this issue?

The goal for this issue was:

Image

and so far we have:

Image

Though realistically if we do want to implement this, it shouldn't be in sqlite3 because it will just create a mess and add too much complex logic to maintain (in a module that should not have it), especially with the tab completion now.

So I propose to just add a Whats New note like was done in 3.13 for the REPL, and we can always reopen in the future.

StanFromIreland avatar Jun 26 '25 12:06 StanFromIreland