Skip to content

Commit

Permalink
Merge pull request #205 from dbcli/check-db-connection
Browse files Browse the repository at this point in the history
Check for a DB connection before running an LLM query.
  • Loading branch information
amjith authored Jan 29, 2025
2 parents fb981ba + 6155cf3 commit 8e57e84
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## TBD
## 1.14.3 - 2025-01-29

### Bug Fixes

* Fix [misleading "0 rows affected" status for CTEs](https://github.com/dbcli/litecli/issues/203)
by never displaying rows affected when the connector tells us -1
* Show an error message when `\llm "question"` is invoked without a database connection.

## 1.14.2 - 2025-01-26

Expand Down
2 changes: 1 addition & 1 deletion litecli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def one_iteration(text=None):
if special.is_llm_command(text):
try:
start = time()
cur = self.sqlexecute.conn.cursor()
cur = self.sqlexecute.conn and self.sqlexecute.conn.cursor()
context, sql = special.handle_llm(text, cur)
if context:
click.echo(context)
Expand Down
2 changes: 2 additions & 0 deletions litecli/packages/special/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ def is_llm_command(command) -> bool:

@export
def sql_using_llm(cur, question=None, verbose=False) -> Tuple[str, Optional[str]]:
if cur is None:
raise RuntimeError("Connect to a datbase and try again.")
schema_query = """
SELECT sql FROM sqlite_master
WHERE sql IS NOT NULL
Expand Down

0 comments on commit 8e57e84

Please sign in to comment.