db.columns
List all columns for a given table.
db.columns table=name [driver=name] [database=name] format=name [--verbose] [--quiet] [--qq] [--ui]
Example:
db.columns table=name format=plain
grass.script.parse_command("db.columns", table, driver="sqlite", database="$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db", format="plain", verbose=None, quiet=None, superquiet=None)
Example:
gs.parse_command("db.columns", table="name", format="json")
grass.tools.Tools.db_columns(table, driver="sqlite", database="$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db", format="plain", verbose=None, quiet=None, superquiet=None)
Example:
tools = Tools()
tools.db_columns(table="name", format="json")
This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.
Parameters
table=name [required]
Name of attribute table
driver=name
Name of database driver
Allowed values: dbf, odbc, ogr, pg, sqlite
Default: sqlite
database=name
Name of database
Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
format=name [required]
Output format
Allowed values: plain, json
Default: plain
plain: Plain text output
json: JSON (JavaScript Object Notation)
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
table : str, required
Name of attribute table
Used as: input, dbtable, name
driver : str, optional
Name of database driver
Used as: input, dbdriver, name
Allowed values: dbf, odbc, ogr, pg, sqlite
Default: sqlite
database : str, optional
Name of database
Used as: input, dbname, name
Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
format : str, required
Output format
Used as: name
Allowed values: plain, json
plain: Plain text output
json: JSON (JavaScript Object Notation)
Default: plain
verbose : bool, optional
Verbose module output
Default: None
quiet : bool, optional
Quiet module output
Default: None
superquiet : bool, optional
Very quiet module output
Default: None
table : str, required
Name of attribute table
Used as: input, dbtable, name
driver : str, optional
Name of database driver
Used as: input, dbdriver, name
Allowed values: dbf, odbc, ogr, pg, sqlite
Default: sqlite
database : str, optional
Name of database
Used as: input, dbname, name
Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
format : str, required
Output format
Used as: name
Allowed values: plain, json
plain: Plain text output
json: JSON (JavaScript Object Notation)
Default: plain
verbose : bool, optional
Verbose module output
Default: None
quiet : bool, optional
Quiet module output
Default: None
superquiet : bool, optional
Very quiet module output
Default: None
Returns:
result : grass.tools.support.ToolResult | None
If the tool produces text as standard output, a ToolResult object will be returned. Otherwise, None
will be returned.
DESCRIPTION
db.columns lists all columns for a given table. Connection to databases are supported through dbf, shp, odbc and pg drivers.
NOTE
If parameters for database connection are already set with db.connect, they are taken as default values and do not need to be specified each time.
EXAMPLES
List columns of a PostgreSQL attribute table
db.columns table=zipcodes_wake driver=pg database=grassdb
If the database parameters are already set, the columns can be listed directly
db.columns table=zipcodes_wake
List columns from Shape file with DBF attribute table
db.columns table=zipcodes_wake driver=dbf database=/grassdata/nc_spm_08/PERMANENT/dbf/
List columns of table in SQLite database
Note that the SQLite backend is the default setting.
db.columns driver=sqlite table=archsites database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
List columns using Python
import grass.script as gs
data = gs.parse_command("db.columns", table="bridges", format="json")
print(data)
Possible output:
['cat', 'OBJECTID', 'BRIDGES__1', 'SIPS_ID', 'TYPE', 'CLASSIFICA', 'BRIDGE_NUM', 'FEATURE_IN', 'FACILITY_C', 'LOCATION', 'YEAR_BUILT', 'WIDTH', 'CO_', 'CO_NAME']
SEE ALSO
db.connect, db.describe, db.drivers, db.droptable, db.execute, db.login, db.tables, GRASS SQL interface
AUTHOR
Radim Blazek, ITC-Irst, Trento, Italy
SOURCE CODE
Available at: db.columns source code
(history)
Latest change: Friday Jul 18 13:59:49 2025 in commit 74ba8df