Note: A new GRASS GIS stable version has been released: GRASS GIS 7.8, available here.
Updated manual page: here
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
Last changed: $Date$ Available at: db.execute source code (history) Note: A new GRASS GIS stable version has been released: GRASS GIS 7.8, available here.
Main index |
Database index |
Topics index |
Keywords index |
Graphical index |
Full index
© 2003-2019
GRASS Development Team,
GRASS GIS 7.4.5dev Reference Manual
AUTHOR
CERL
SOURCE CODE
Updated manual page: here