Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gvoysey opened this issue May 3, 2024 · 4 comments · Fixed by #177
Closed

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

gvoysey opened this issue May 3, 2024 · 4 comments · Fixed by #177

Comments

@gvoysey
Copy link

gvoysey commented May 3, 2024

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",]:

litecli/litecli/main.py

Lines 591 to 596 in 9d5bcf0

for command in self.startup_commands["commands"]:
try:
res = sqlexecute.run(command)
except Exception as e:
click.echo(command)
self.echo(str(e), err=True, fg="red")

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

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

@amjith
Copy link
Member

amjith commented May 3, 2024

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

@gvoysey
Copy link
Author

gvoysey commented May 3, 2024

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 amjith mentioned this issue May 3, 2024
1 task
@amjith
Copy link
Member

amjith commented May 3, 2024

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

@gvoysey
Copy link
Author

gvoysey commented May 3, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants