File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88from pt_snap_cli import __version__
99from pt_snap_cli .config import ENV_DB_PATH , Config , ContextResolutionError
10- from pt_snap_cli .context import Context
10+ from pt_snap_cli .context import Context , DatabaseNotFoundError , SchemaVersionError
1111
1212app = typer .Typer (
1313 name = "pt-snap" ,
@@ -101,9 +101,12 @@ def use_database(
101101 typer .echo (f"Available devices: { ', ' .join (map (str , devices ))} " )
102102 else :
103103 typer .echo ("No devices found in database." )
104- except Exception as e :
104+ except ( DatabaseNotFoundError , SchemaVersionError ) as e :
105105 typer .secho (f"Error: { e } " , fg = typer .colors .RED )
106106 raise typer .Exit (1 ) from None
107+ except Exception as e :
108+ typer .secho (f"Error: unexpected failure opening database: { e } " , fg = typer .colors .RED )
109+ raise typer .Exit (1 ) from None
107110
108111
109112@app .command ("query" )
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ def execute(
120120 else :
121121 cursor .execute (sql )
122122 columns = [desc [0 ] for desc in cursor .description ]
123- return [dict (zip (columns , row , strict = False )) for row in cursor .fetchall ()]
123+ return [dict (zip (columns , row , strict = True )) for row in cursor .fetchall ()]
124124 except Exception as e :
125125 raise QueryExecutionError (f"Query execution failed: { e } " ) from e
126126
You can’t perform that action at this time.
0 commit comments