Note: This document is for an older version of GRASS GIS that has been discontinued. 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 Jan 26 14:10:26 2023 in commit: cdd84c130cea04b204479e2efdc75c742efc4843
Main index |
Database index |
Topics index |
Keywords index |
Graphical index |
Full index
© 2003-2024
GRASS Development Team,
GRASS GIS 8.3.3dev Reference Manual
AUTHOR
CERL
SOURCE CODE