[GRASS-dev] no way to ID table columns outside of working mapset?

I'm working on a fix for vector attribute column selection in the wxGUI and discovered that I can't find a way to get the columns for an attribute table for a vector not in the current working mapset. v.db.connect and db.columns won't accept fully qualified map names. Is this something that needs to be fixed or is there a workaround that I didn't see?

Michael
______________________________
C. Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262; fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Hi,

2008/9/8 Michael Barton <michael.barton@asu.edu>:

I'm working on a fix for vector attribute column selection in the wxGUI and
discovered that I can't find a way to get the columns for an attribute table
for a vector not in the current working mapset. v.db.connect and db.columns

v.info -c, see

http://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/gui_modules/menuform.py#L1410

M.

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

On 08/09/08 17:43, Michael Barton wrote:

I'm working on a fix for vector attribute column selection in the wxGUI and discovered that I can't find a way to get the columns for an attribute table for a vector not in the current working mapset. v.db.connect and db.columns won't accept fully qualified map names. Is this something that needs to be fixed or is there a workaround that I didn't see?

Martin already gave you v.info, but db.columns is not related to a mapset (not even necessarily related to vector attribute tables) and thus works with any table,database,driver combination you give it.

And, v.db.connect does accept fully qualified in grass7:

GRASS 7.0.svn (nc_spm_06):~ > g.mapsets -p
user2 user1 PERMANENT

GRASS 7.0.svn (nc_spm_06):~ > v.db.connect -p mygeodetic_pts@sqlite
Vector map <mygeodetic_pts@sqlite> is connected by:
layer <1> table <mygeodetic_pts> in database </home/mlennert/GRASS/DATA/nc_spm_06/sqlite/sqlite.db> through driver <sqlite> with key <cat>

Can't test 6.4 right now...but I guess this is linked to Glynn's recent changes.

Moritz

Thanks Moritz,

On Sep 8, 2008, at 9:07 AM, Moritz Lennert wrote:

On 08/09/08 17:43, Michael Barton wrote:

I'm working on a fix for vector attribute column selection in the wxGUI and discovered that I can't find a way to get the columns for an attribute table for a vector not in the current working mapset. v.db.connect and db.columns won't accept fully qualified map names. Is this something that needs to be fixed or is there a workaround that I didn't see?

Martin already gave you v.info, but db.columns is not related to a mapset (not even necessarily related to vector attribute tables) and thus works with any table,database,driver combination you give it.

v.info will probably do the trick.

db.columns will return simply the columns without specifying the database and driver if it is for a vector whose connection is already set. Otherwise, it's not particularly easy to find out the database and driver for an attribute table connected to a vector that is not in the current working mapset because the commands will not accept a fully qualified name.

And, v.db.connect does accept fully qualified in grass7:

Can this be backported to 6.4?

Michael

GRASS 7.0.svn (nc_spm_06):~ > g.mapsets -p
user2 user1 PERMANENT

GRASS 7.0.svn (nc_spm_06):~ > v.db.connect -p mygeodetic_pts@sqlite
Vector map <mygeodetic_pts@sqlite> is connected by:
layer <1> table <mygeodetic_pts> in database </home/mlennert/GRASS/DATA/nc_spm_06/sqlite/sqlite.db> through driver <sqlite> with key <cat>

Can't test 6.4 right now...but I guess this is linked to Glynn's recent changes.

Moritz

Hi,

2008/9/8 Michael Barton <michael.barton@asu.edu>:

And, v.db.connect does accept fully qualified in grass7:

Can this be backported to 6.4?

I think nothing need to be backported, v.db.connect seems to work with
fully qualified names.

v.db.connect -g P079214@PERMANENT
1/VEG_TREE_BL P079214 cat /home/martin/grassdata/nc_spm_08/PERMANENT/dbf/ dbf

v.db.connect -g P079214
WARNING: 'vector/P079214' was found in more mapsets (also found in
         PERMANENT).
WARNING: using 'P079214@martin'.
1/VEG_TREE_BL P079214 cat /home/martin/grassdata/nc_spm_08/martin/dbf/ dbf

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

Hi,

2008/9/8 Michael Barton <michael.barton@asu.edu>:

v.info will probably do the trick.

db.columns will return simply the columns without specifying the database
and driver if it is for a vector whose connection is already set. Otherwise,
it's not particularly easy to find out the database and driver for an
attribute table connected to a vector that is not in the current working
mapset because the commands will not accept a fully qualified name.

v.info is good candidate for this work, see menuform.py ...

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

You are correct. This didn't seem to work when I tested it last night. v.info -c is a problem because it does not give a list of defined layers; you have to know which layer you want to look at and tell it.

Michael
______________________________
C. Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262; fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

On Sep 8, 2008, at 9:50 AM, Martin Landa wrote:

Hi,

2008/9/8 Michael Barton <michael.barton@asu.edu>:

And, v.db.connect does accept fully qualified in grass7:

Can this be backported to 6.4?

I think nothing need to be backported, v.db.connect seems to work with
fully qualified names.

v.db.connect -g P079214@PERMANENT
1/VEG_TREE_BL P079214 cat /home/martin/grassdata/nc_spm_08/PERMANENT/dbf/ dbf

v.db.connect -g P079214
WARNING: 'vector/P079214' was found in more mapsets (also found in
        PERMANENT).
WARNING: using 'P079214@martin'.
1/VEG_TREE_BL P079214 cat /home/martin/grassdata/nc_spm_08/martin/dbf/ dbf

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

On 08/09/08 18:46, Michael Barton wrote:

Thanks Moritz,

On Sep 8, 2008, at 9:07 AM, Moritz Lennert wrote:

On 08/09/08 17:43, Michael Barton wrote:

I'm working on a fix for vector attribute column selection in the wxGUI and discovered that I can't find a way to get the columns for an attribute table for a vector not in the current working mapset. v.db.connect and db.columns won't accept fully qualified map names. Is this something that needs to be fixed or is there a workaround that I didn't see?

Martin already gave you v.info, but db.columns is not related to a mapset (not even necessarily related to vector attribute tables) and thus works with any table,database,driver combination you give it.

v.info will probably do the trick.

db.columns will return simply the columns without specifying the database and driver if it is for a vector whose connection is already set.

No. It will only do this in the case that the table connected to the vector has the same name as the map _and_ that the current database connection parameters defined by db.connect are identical to those of the specific vector. Both of these are not guaranteed, so one should never rely on them (ISTR that some other modules do - mostly scripts, which IMHO is a bug).

As I said, there is no link to _maps_ in db.connect.

Moritz