mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-12 03:24:23 +02:00
Fix type errors in cli.py and db.py
- Add type annotation for Database.conn to fix context manager errors - Convert exception objects to str() when raising ClickException - Handle None return from find_spatialite() with proper error message 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
116cc99791
commit
29842be858
2 changed files with 8 additions and 4 deletions
|
|
@ -393,7 +393,7 @@ def analyze(path, names):
|
|||
else:
|
||||
db.analyze()
|
||||
except OperationalError as e:
|
||||
raise click.ClickException(e)
|
||||
raise click.ClickException(str(e))
|
||||
|
||||
|
||||
@cli.command()
|
||||
|
|
@ -536,7 +536,7 @@ def add_foreign_key(
|
|||
try:
|
||||
db[table].add_foreign_key(column, other_table, other_column, ignore=ignore)
|
||||
except AlterError as e:
|
||||
raise click.ClickException(e)
|
||||
raise click.ClickException(str(e))
|
||||
|
||||
|
||||
@cli.command(name="add-foreign-keys")
|
||||
|
|
@ -571,7 +571,7 @@ def add_foreign_keys(path, foreign_key, load_extension):
|
|||
try:
|
||||
db.add_foreign_keys(tuples)
|
||||
except AlterError as e:
|
||||
raise click.ClickException(e)
|
||||
raise click.ClickException(str(e))
|
||||
|
||||
|
||||
@cli.command(name="index-foreign-keys")
|
||||
|
|
@ -3361,7 +3361,10 @@ def _load_extensions(db, load_extension):
|
|||
db.conn.enable_load_extension(True)
|
||||
for ext in load_extension:
|
||||
if ext == "spatialite" and not os.path.exists(ext):
|
||||
ext = find_spatialite()
|
||||
found = find_spatialite()
|
||||
if found is None:
|
||||
raise click.ClickException("Could not find SpatiaLite extension")
|
||||
ext = found
|
||||
if ":" in ext:
|
||||
path, _, entrypoint = ext.partition(":")
|
||||
db.conn.execute("SELECT load_extension(?, ?)", [path, entrypoint])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue