other versions
- jessie 6.4.4-1
- stretch 7.2.0-2
- testing 7.6.0-1
- unstable 7.6.0-1
- experimental 7.6.1-1~exp1
| v.db.connect(1grass) | Grass User's Manual | v.db.connect(1grass) |
NAME¶
v.db.connect - Prints/sets DB connection for a vector map to attribute table.KEYWORDS¶
vector, database, attribute tableSYNOPSIS¶
v.db.connectFlags:¶
- -p
-
Print all map connection parameters and exit
- -g
-
Print all map connection parameters and exit in shell script styleFormat: layer[/layer name] table key database driver
- -l
-
When printing, limit to layer specified by the layer option
- -c
-
Print types/names of table columns for specified layer and exit
- -o
-
Overwrite connection parameter for certain layer
- -d
-
Delete connection for certain layer (not the table)
- --verbose
-
Verbose module output
- --quiet
-
Quiet module output
Parameters:¶
- map=name
-
Name of input vector map
- driver=name
-
Driver nameOptions: pg,dbf,ogr,odbc,mysql,sqliteDefault: dbf
- database=name
-
Database nameDefault: $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/
- table=name
-
Table name
- key=name
-
Key column nameMust refer to an integer columnDefault: cat
- layer=integer
-
Layer numberA single vector map can be connected to multiple database tables. This number determines which table to use.Default: 1
- fs=character
-
Field separatorField separator for shell script style outputDefault:
DESCRIPTION¶
v.db.connect prints or sets database connection for a vector map. The user can add or remove link to attribute table on the certain layer.NOTE¶
If parameters for database connection are already set with db.connect, they are taken as default values and do not need to be spcified each time. When printing database connection ( p or g flag) the parameter layer is ignored, i.e. all connections are printed to the output, unless l flag is given. Attention: Removing a vector map will also delete all tables linked to it! If you use v.db.connect to link further tables to your map, it is advisable to make a copy from those tables first and connect the copied tables to the vector map (see also v.overlay).EXAMPLE¶
Print database connection¶
Print all database connection parameters for vector map.Connect vector map to database (DBF driver)¶
Connect vector map to DBF table without or with variables.database=/home/user/grassdata/spearfish60/PERMANENT/dbf
database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
Connect vector map to database (SQLite driver)¶
Very similar to DBF driver example above.database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db'
Connect vector map to database (MySQL driver)¶
Connect vector map to database (PostgreSQL driver)¶
database="host=myserver.itc.it,dbname=mydb,user=name" \
table=mytable key=id
Store geometry in GRASS but attributes in PostgreSQL¶
This example illustrated a mixed data storage with possibility top update attributes in external PostgreSQL database:table=mytable x=lon y=lat key=cat out=mytable
table=mytable key=cat
Store geometry in GRASS but attributes in PostGIS¶
This example illustrated a mixed data storage with possibility top update attributes in external PostGIS database:table=mytable x="x(geom)" y="y(geom)" key=cat out=mytable
table=mytable key=cat
SEE ALSO¶
db.connect, db.copy, db.tables, v.db.addtable, v.db.droptable, v.db.addcol, v.db.dropcol, v.external, v.in.db, v.overlayAUTHOR¶
Radim Blazek, ITC-Irst, Trento, Italy Last changed: $Date: 2011-11-08 12:29:50 +0100 (Tue, 08 Nov 2011) $ Full index © 2003-2014 GRASS Development Team| GRASS 6.4.4 |