diff options
-rw-r--r-- | .github/workflows/ci.yml | 2 | ||||
-rw-r--r-- | CHANGELOG.md | 20 | ||||
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | TODO.md | 6 | ||||
-rw-r--r-- | litecli/__init__.py | 2 | ||||
-rw-r--r-- | litecli/config.py | 6 | ||||
-rw-r--r-- | litecli/liteclirc | 4 | ||||
-rw-r--r-- | litecli/main.py | 22 | ||||
-rw-r--r-- | litecli/packages/special/dbcommands.py | 2 |
9 files changed, 50 insertions, 17 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ee36cf..d4de9d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 808b8df..9530cd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +## 1.11.0 - 2024-05-03 + +### Improvements + +* When an empty `\d` is invoked the list of tables are returned instead of an error. +* Show SQLite version at startup. + + +### Bug Fixes + +* Support a single item in the startup commands in the config. (bug #176) + + +## 1.10.1 - 2024-3-23 + +### Bug Fixes + +* Do not crash at start up if ~/.config/litecli is not writeable. [#172](https://github.com/dbcli/litecli/issues/172) + + ## 1.10.0 - 2022-11-19 ### Features @@ -1,3 +0,0 @@ -* [] Sort by frecency. -* [] Add completions when an attach database command is run. -* [] Add behave tests. @@ -0,0 +1,6 @@ +* [ ] Change to use ruff +* [ ] Automate the release process via GH actions. [Article](https://simonwillison.net/2024/Jan/16/python-lib-pypi/) + +* [] Sort by frecency. +* [] Add completions when an attach database command is run. +* [] Add behave tests. diff --git a/litecli/__init__.py b/litecli/__init__.py index fcfdf38..f84c53b 100644 --- a/litecli/__init__.py +++ b/litecli/__init__.py @@ -1 +1 @@ -__version__ = "1.10.0" +__version__ = "1.11.0" diff --git a/litecli/config.py b/litecli/config.py index 1c7fb25..55d3e32 100644 --- a/litecli/config.py +++ b/litecli/config.py @@ -57,6 +57,10 @@ def get_config(liteclirc_file=None): liteclirc_file = liteclirc_file or "%sconfig" % config_location() default_config = os.path.join(package_root, "liteclirc") - write_default_config(default_config, liteclirc_file) + try: + write_default_config(default_config, liteclirc_file) + except OSError: + # If we can't write to the config file, just use the default config + return load_config(default_config) return load_config(liteclirc_file, default_config) diff --git a/litecli/liteclirc b/litecli/liteclirc index 924b585..1184278 100644 --- a/litecli/liteclirc +++ b/litecli/liteclirc @@ -122,7 +122,7 @@ output.even-row = "" # Startup commands # litecli commands or sqlite commands to be executed on startup. -# some of them will require you to have a database attached. +# some of them will require you to have a database attached. # they will be executed in the same order as they appear in the list. [startup_commands] -#commands = ".tables", "pragma foreign_keys = ON;"
\ No newline at end of file +#commands = ".tables", "pragma foreign_keys = ON;" diff --git a/litecli/main.py b/litecli/main.py index e608da7..ebbc5ba 100644 --- a/litecli/main.py +++ b/litecli/main.py @@ -10,7 +10,7 @@ from time import time from datetime import datetime from io import open from collections import namedtuple -from sqlite3 import OperationalError +from sqlite3 import OperationalError, sqlite_version import shutil from cli_helpers.tabular_output import TabularOutputFormatter @@ -239,7 +239,11 @@ class LiteCli(object): log_file = self.config["main"]["log_file"] if log_file == "default": log_file = config_location() + "log" - ensure_dir_exists(log_file) + try: + ensure_dir_exists(log_file) + except OSError: + # Unable to create log file, log to temp directory instead. + log_file = "/tmp/litecli.log" log_level = self.config["main"]["log_level"] @@ -376,10 +380,8 @@ class LiteCli(object): key_bindings = cli_bindings(self) if not self.less_chatty: - print("Version:", __version__) - print("Mail: https://groups.google.com/forum/#!forum/litecli-users") + print(f"LiteCli: {__version__} (SQLite: {sqlite_version})") print("GitHub: https://github.com/dbcli/litecli") - # print("Home: https://litecli.com") def get_message(): prompt = self.get_prompt(self.prompt_format) @@ -584,7 +586,11 @@ class LiteCli(object): def startup_commands(): if self.startup_commands: if "commands" in self.startup_commands: - for command in self.startup_commands["commands"]: + if isinstance(self.startup_commands["commands"], str): + commands = [self.startup_commands["commands"]] + else: + commands = self.startup_commands["commands"] + for command in commands: try: res = sqlexecute.run(command) except Exception as e: @@ -815,7 +821,7 @@ class LiteCli(object): headers, format_name="vertical" if expanded else None, column_types=column_types, - **output_kwargs + **output_kwargs, ) if isinstance(formatted, (text_type)): @@ -837,7 +843,7 @@ class LiteCli(object): headers, format_name="vertical", column_types=column_types, - **output_kwargs + **output_kwargs, ) if isinstance(formatted, (text_type)): formatted = iter(formatted.splitlines()) diff --git a/litecli/packages/special/dbcommands.py b/litecli/packages/special/dbcommands.py index dec3507..687c9a4 100644 --- a/litecli/packages/special/dbcommands.py +++ b/litecli/packages/special/dbcommands.py @@ -224,7 +224,7 @@ def describe(cur, arg, **_): arg ) else: - raise ArgumentMissing("Table name required.") + return list_tables(cur) log.debug(query) cur.execute(query) |