Skip to content

db.join

Joins a database table to another database table.

db.join table=name column=name [database=name] [driver=name] other_table=name other_column=name [subset_columns=name [,name,...]] [--verbose] [--quiet] [--qq] [--ui]

Example:

db.join table=name column=name other_table=name other_column=name

grass.script.run_command("db.join", table, column, database=None, driver=None, other_table, other_column, subset_columns=None, verbose=None, quiet=None, superquiet=None)

Example:

gs.run_command("db.join", table="name", column="name", other_table="name", other_column="name")

grass.tools.Tools.db_join(table, column, database=None, driver=None, other_table, other_column, subset_columns=None, verbose=None, quiet=None, superquiet=None)

Example:

tools = Tools()
tools.db_join(table="name", column="name", other_table="name", other_column="name")

This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.

Parameters

table=name [required]
    Table to which to join other table
column=name [required]
    Identifier column (e.g.: cat) in the table to be used for join
database=name
    Name of database
driver=name
    Name of database driver
    Allowed values: dbf, odbc, ogr, sqlite, pg
other_table=name [required]
    Other table name
other_column=name [required]
    Identifier column (e.g.: id) in the other table used for join
subset_columns=name [,name,...]
    Subset of columns from the other table
--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
    Table to which to join other table
    Used as: input, dbtable, name
column : str, required
    Identifier column (e.g.: cat) in the table to be used for join
    Used as: input, dbcolumn, name
database : str, optional
    Name of database
    Used as: input, dbname, name
driver : str, optional
    Name of database driver
    Used as: input, dbdriver, name
    Allowed values: dbf, odbc, ogr, sqlite, pg
other_table : str, required
    Other table name
    Used as: input, dbtable, name
other_column : str, required
    Identifier column (e.g.: id) in the other table used for join
    Used as: input, dbcolumn, name
subset_columns : str | list[str], optional
    Subset of columns from the other table
    Used as: input, dbcolumn, name
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
    Table to which to join other table
    Used as: input, dbtable, name
column : str, required
    Identifier column (e.g.: cat) in the table to be used for join
    Used as: input, dbcolumn, name
database : str, optional
    Name of database
    Used as: input, dbname, name
driver : str, optional
    Name of database driver
    Used as: input, dbdriver, name
    Allowed values: dbf, odbc, ogr, sqlite, pg
other_table : str, required
    Other table name
    Used as: input, dbtable, name
other_column : str, required
    Identifier column (e.g.: id) in the other table used for join
    Used as: input, dbcolumn, name
subset_columns : str | list[str], optional
    Subset of columns from the other table
    Used as: input, dbcolumn, name
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.join joins the content of one attribute table into another attribute table through common attributes.

NOTES

db.join is a front-end to db.execute to allow easier usage. The attribute table must be stored in a SQL database (SQLite, PostgreSQL, MySQL, ODBC, ...). The DBF backend is not supported. Tables can be imported with db.in.ogr.

EXAMPLES

# join soils_legend into mysoils attribute table
db.join mysoils col=label otable=soils_legend ocol=shortname

# verification of join
db.select mysoils
cat|label|id|shortname|longname
1|Aab|||
2|Ba|2|Ba|Barnum silt loam
3|Bb|3|Bb|Barnum silt loam, channeled
4|BcB|4|BcB|Boneek silt loam, 2 to 6
5|BcC|5|BcC|Boneek silt loam, 6 to 9
...

SEE ALSO

db.execute, db.in.ogr, db.select, v.db.join, v.db.update
GRASS SQL interface

AUTHOR

Markus Neteler

SOURCE CODE

Available at: db.join source code (history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819