dbcli / litecli

CLI for SQLite Databases with auto-completion and syntax highlighting
https://litecli.com
BSD 3-Clause "New" or "Revised" License
2.06k stars 67 forks source link

`startup_commands` fails when config value is a single string. #176

Closed gvoysey closed 2 months ago

gvoysey commented 2 months ago

Using litecli version 1.10.1, installed with pipx on linux; base python is a pyenv-installed 3.10.10.

Given the following contents of ~/.config/litecli/config:

[startup_commands]
commands = ".tables"

loading litecli fails:

.
Could not execute all startup commands:
Not connected to database.
(none)>

If the config is changed to add a trailing comma:

[startup_commands]
commands = ".tables",

then the .tables command is correctly executed.

I suspect this is because without the comma, python is iterating the over the string ".tables", not the list [".tables",]: https://github.com/dbcli/litecli/blob/9d5bcf0ba17fd0562309164175d7db1a54f85464/litecli/main.py#L591-L596

Adding a print above L592 confirms.
Without a comma: self.startup_commands={'commands': '.tables'}

With a comma: self.startup_commands={'commands': ['.tables']}

amjith commented 2 months ago

That is quite the embarrassing bug. Thanks for reporting it. Looking into it now.

gvoysey commented 2 months ago

if it's any consolation, i accidentally loop over the characters of a string instead of strings in a list at least once a quarter!

amjith commented 2 months ago

I've released a new version with the bug fix. Thanks again for reporting.

gvoysey commented 2 months ago

thanks for the super fast reply! I found this while figuring out how to auto-load spatialite ( ref #127 ) -- which also works. Much nicer than futzing around waiting for datagrip to fire up.

On Fri, May 3, 2024 at 1:35 PM Amjith Ramanujam @.***> wrote:

I've released a new version with the bug fix. Thanks again for reporting.

— Reply to this email directly, view it on GitHub https://github.com/dbcli/litecli/issues/176#issuecomment-2093473798, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3ZD32J3CVH7T2SVNYSJK3ZAPDEXAVCNFSM6AAAAABHFRUIX6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJTGQ3TGNZZHA . You are receiving this because you authored the thread.Message ID: @.***>