mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
Turn SQL errors into click errors
This commit is contained in:
parent
78aebb6479
commit
287cdcae89
2 changed files with 5 additions and 2 deletions
|
|
@ -1088,7 +1088,10 @@ def query(
|
|||
_load_extensions(db, load_extension)
|
||||
db.register_fts4_bm25()
|
||||
with db.conn:
|
||||
cursor = db.execute(sql, dict(param))
|
||||
try:
|
||||
cursor = db.execute(sql, dict(param))
|
||||
except sqlite3.OperationalError as e:
|
||||
raise click.ClickException(str(e))
|
||||
if cursor.description is None:
|
||||
# This was an update/insert
|
||||
headers = ["rows_affected"]
|
||||
|
|
|
|||
|
|
@ -1049,7 +1049,7 @@ def test_query_load_extension(use_spatialite_shortcut):
|
|||
# Without --load-extension:
|
||||
result = CliRunner().invoke(cli.cli, [":memory:", "select spatialite_version()"])
|
||||
assert result.exit_code == 1
|
||||
assert "no such function: spatialite_version" in repr(result)
|
||||
assert "no such function: spatialite_version" in result.output
|
||||
# With --load-extension:
|
||||
if use_spatialite_shortcut:
|
||||
load_extension = "spatialite"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue