Note: This document is for an older version of GRASS GIS that is outdated. You should upgrade, and read the current manual page.
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.
If you have a large number of SQL commands to process, it is much much faster to place all the SQL statements into a text file and use input file parameter than it is to process each statement individually in a loop. If multiple instruction lines are given, each SQL line must end with a semicolon.
Please see the individual GRASS SQL interface for how to create a new database.
db.execute sql="CREATE TABLE soils (cat integer, soiltype varchar(10))"
db.execute driver=odbc database=grassdb input=file.sql
db.execute sql="INSERT INTO mysites (id,name,east,north) values (30,'Ala',1657340,5072301)"
db.execute sql="UPDATE roads SET travelcost=5 WHERE cat=1"
db.execute sql="UPDATE dourokukan SET testc=50 WHERE testc is NULL"
db.execute sql="DELETE FROM gsod_stationlist WHERE latitude < -91"
db.execute sql="ALTER TABLE roads ADD COLUMN length double"
# 'z_value' is varchar and 'z' is double precision: echo "UPDATE geodetic_pts SET z = CAST(z_value AS numeric)" | db.execute input=-
db.execute sql="ALTER TABLE roads DROP COLUMN length"
db.execute sql="DROP TABLE fmacopy"
UPDATE roads SET travelcost=5 WHERE cat=1; UPDATE roads SET travelcost=2 WHERE cat=2; db.execute input=file.sql
db.execute sql="UPDATE extratab SET names=(SELECT label FROM myroads WHERE extratab.cat=myroads.cat)"
GRASS SQL interface
Available at:
db.execute source code
(history)
Latest change: Thu Feb 3 11:10:06 2022 in commit: 73413160a81ed43e7a5ca0dc16f0b56e450e9fef
Main index |
Database index |
Topics index |
Keywords index |
Graphical index |
Full index
© 2003-2022
GRASS Development Team,
GRASS GIS 8.0.3dev Reference Manual
AUTHOR
CERLSOURCE CODE