[GRASS-dev] possible error in WIKI could cause data corruption

Michael Barton Michael.Barton at asu.edu
Sat Sep 5 10:51:01 PDT 2015


I don’t know if this is bad advice in the GRASS WIKI or a bug in a GRASS database module. I have some vector files that were somehow imported into a dbf DBMS last year. I wanted to switch them all to sqlite. The GRASS WIKI advises…

Convert automatically all GRASS 6 vector maps to GRASS 7 (including attribute transfer from DBF to SQLite)

To become readable in GRASS 7, all vector maps in a mapset need to be updated to the improved vector file format (i.e., rebuild the topology with v.build.all along with the change to the SQLite database backend (SQLite is the new default in GRASS 7 instead of DBF in GRASS 6, using db.connect and v.db.reconnect.all).

Run this in GRASS GIS 7:

# first rebuild topology for all vector maps in current mapset
v.build.all

# define new default DB connection (switch from DBF to SQLite)
db.connect -d

# transfer all attribute tables from DBF to SQLite and clean old DBF tables
v.db.reconnect.all -cd


The vectors already had GRASS 7 topology, but I ran v.rebuild.all just to be sure. No problem.

db.connect -d ran with no problem

But v.db.reconnect.all -cd did not create tables in the sqlite database and corrupted the existing connection of the first table it hit. Fortunately, I made a backup of the mapset before I started this.

GRASS 7.1.svn (Spain_fieldwork_medlands_ERTS89_Z30):~ > v.db.reconnect.all -cd

--------------------------------------------------------------------------------
Reconnecting vector map <catastro at surveyboundaries> (1 of 9)...
--------------------------------------------------------------------------------
Copying table <catastro> to target database...
Traceback (most recent call last):
  File "/Applications/GRASS/GRASS-7.1.app/Contents/MacOS/scripts/db.droptable", line 99, in <module>
    main()
  File "/Applications/GRASS/GRASS-7.1.app/Contents/MacOS/scripts/db.droptable", line 77, in main
    used = grass.db.db_table_in_vector(table)
  File "/Applications/GRASS/GRASS-7.1.app/Contents/MacOS/etc/python/grass/script/db.py", line 184, in db_table_in_vector
    from vector import vector_db
ImportError: No module named vector
ERROR: Unable to drop table <catastro>
GRASS 7.1.svn (Spain_fieldwork_medlands_ERTS89_Z30):~ >

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Head, Graduate Faculty in Complex Adaptive Systems Science
Arizona State University

voice:  480-965-6262 (SHESC), 480-965-8130/727-9746 (CSDC)
fax: 480-965-7671 (SHESC),  480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu















-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20150905/bf86321c/attachment-0001.html>


More information about the grass-dev mailing list