Skip to content

[Bug] db.univar fails with Python error when input table not existing #3760

Open
@neteler

Description

@neteler

Describe the bug

db.univar fails with Python error when input table not existing.

To reproduce

GRASS nc_spm_08_grass7/user1: > db.univar bla column=value
WARNING: Table <bla> not found in database
         <$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db> using driver
         <sqlite>
Traceback (most recent call last):
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/scripts/db.univar", line 384, in <module>
    main()
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/scripts/db.univar", line 130, in main
    desc_table = gscript.db_describe(table, database=database, driver=driver)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/etc/python/grass/script/db.py", line 56, in db_describe
    s = read_command("db.describe", flags="c", table=table, env=env, **args)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 554, in read_command
    return handle_errors(returncode, stdout, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 366, in handle_errors
    raise CalledModuleError(module=module, code=code, returncode=returncode)
grass.exceptions.CalledModuleError: Module run `db.describe -c table=bla` ended with an error.
The subprocess ended with a non-zero return code: 1. See errors above the traceback or in the error output.

Expected behavior

db.univar should print an error message when input table is not existing.

System description

  • Operating System: Fedora Linux 39
  • GRASS GIS version:
g.version -rge
version=8.4.0dev
date=2024
revision=f4d8c62acd
build_date=2024-05-24
build_platform=x86_64-pc-linux-gnu
build_off_t_size=8
libgis_revision=23c0db50ff
libgis_date=2024-04-16T19:27:24+00:00
proj=9.2.1
gdal=3.7.3
geos=3.12.1
sqlite=3.42.0

Additional context

db.univar is called by v.db.univar and other modules which would benefit from a proper catch-error in db.univar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PythonRelated code is in PythonbugSomething isn't workingdatabaseRelated to database management

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions