Note: This document is for an older version of GRASS GIS that will be discontinued soon. 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: Thursday Feb 03 11:10:06 2022 in commit: 547ff44e6aecfb4c9cbf6a4717fc14e521bec0be
Note: This document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade, and read the current manual page.
Main index |
Database index |
Topics index |
Keywords index |
Graphical index |
Full index
© 2003-2023
GRASS Development Team,
GRASS GIS 8.2.2dev Reference Manual
AUTHOR
CERLSOURCE CODE