Note: This document is for an older version of GRASS GIS that is outdated. You should upgrade, and read the current manual page.
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).
v.db.connect -p map=roads
Print column types and names of table linked to vector map.
v.db.connect -c map=roads
Using default DB connection:
v.db.connect map=vectormap table=table
Using hardcoded path to DBF directory (not recommended):
v.db.connect map=vectormap table=table \ database=/home/user/grassdata/spearfish60/PERMANENT/dbf
Using variable as DBF directory definition, single quotes must be used:
v.db.connect map=vectormap table=table \ database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
Connect vector map layer 2 and key ID to database with variables (note: if needed, single quotes must be used for the database parameter):
v.db.connect map=vectormap table=table layer=2 key=ID
db.connect driver=sqlite database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db' db.tables -p v.db.connect map=vectormap table=table driver=sqlite \ database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db' v.db.connect -p map=vectormap
# note: connection which requires password db.connect driver=mysql database="host=dbserver.foo.org,dbname=my_database" db.login user=joshua [password=xxx] # ... or enter password interactively. db.tables -p # connect external table to layer 2: v.db.connect map=my_map table=my_mysql_table key=baz layer=2 v.db.connect -p my_map
# note: connection without password being asked v.db.connect map=vectormap table=table layer=1 key=oid driver=pg \ database="host=myserver.itc.it,dbname=mydb,user=name" \ table=mytable key=id
# Check current settings for attribute storage: db.connect -p # Import table from PostgreSQL to new map # (NOTE: output map name needs to be different from table name in # case that GRASS is connected to PostgreSQL): v.in.db driver=pg database="host=localhost,dbname=meteo" \ table=mytable x=lon y=lat key=cat out=mytable v.db.connect map=mytable -p # Cancel table connection between map and attribute table: v.db.connect map=mytable -d v.db.connect map=mytable -p # Drop table which was replicated due to import: db.tables -p echo "DROP TABLE mytable" | db.execute db.tables -p # reconnect map to table in PostgreSQL: v.db.connect map=mytable driver=pg database="host=localhost,dbname=meteo" \ table=mytable key=cat # Now the geometry is stored in GRASS while the attributes are stored # in PostgreSQL.
# Check current settings for attribute storage: db.connect -p # Import table from PostGIS to new map # (NOTE: output map name needs to be different from table name in # case that GRASS is connected to PostGIS): v.in.db driver=pg database="host=localhost,dbname=meteo" \ table=mytable x="x(geom)" y="y(geom)" key=cat out=mytable v.db.connect map=mytable -p # Cancel table connection between map and attribute table: v.db.connect map=mytable -d v.db.connect map=mytable -p # Drop table which was replicated due to import: db.tables -p echo "DROP TABLE mytable" | db.execute db.tables -p # reconnect map to table in PostGIS: v.db.connect map=mytable driver=pg database="host=localhost,dbname=meteo" \ table=mytable key=cat # Now the geometry is stored in GRASS while the attributes are stored # in PostGIS.
Last changed: $Date: 2011-11-08 03:23:06 -0800 (Tue, 08 Nov 2011) $
Main index - vector index - Full index
© 2003-2014 GRASS Development Team