Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/pt_snap_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from pt_snap_cli import __version__
from pt_snap_cli.config import ENV_DB_PATH, Config, ContextResolutionError
from pt_snap_cli.context import Context
from pt_snap_cli.context import Context, DatabaseNotFoundError, SchemaVersionError

app = typer.Typer(
name="pt-snap",
Expand Down Expand Up @@ -101,9 +101,12 @@ def use_database(
typer.echo(f"Available devices: {', '.join(map(str, devices))}")
else:
typer.echo("No devices found in database.")
except Exception as e:
except (DatabaseNotFoundError, SchemaVersionError) as e:
typer.secho(f"Error: {e}", fg=typer.colors.RED)
raise typer.Exit(1) from None
except Exception as e:
typer.secho(f"Error: unexpected failure opening database: {e}", fg=typer.colors.RED)
raise typer.Exit(1) from None


@app.command("query")
Expand Down
2 changes: 1 addition & 1 deletion src/pt_snap_cli/query/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def execute(
else:
cursor.execute(sql)
columns = [desc[0] for desc in cursor.description]
return [dict(zip(columns, row, strict=False)) for row in cursor.fetchall()]
return [dict(zip(columns, row, strict=True)) for row in cursor.fetchall()]
except Exception as e:
raise QueryExecutionError(f"Query execution failed: {e}") from e

Expand Down
Loading