[GRASS5] db.connect and auto-creation of dbf/ directory

Hamish hamish_nospam at yahoo.com
Fri Apr 22 06:45:54 EDT 2005


> > > when using db.connect to define in a new mapset the DB connection,
> > > I face following non-feature:
> > > 
> > > db.connect driver=dbf
> > > database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/' db.connect -p
> > > driver:dbf
> > > database:$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/
> > > schema:(null)
> > > group:(null)
> > > 
> > > So far so nice. But:
> > > 
> > > g.copy vect=ammprv,pat_ammprv
> > > COPY [ammprv at PERMANENT] to current mapset as [pat_ammprv]
> > > DBMI-DBF driver error:
> > > Cannot open dbf database:
> > > /ssi0/ssi/neteler/grassdata/pat/export/dbf/
> > > 
> > > WARNING: Cannot open database
> > > '/ssi0/ssi/neteler/grassdata/pat/export/dbf/' no database is open
> > > WARNING: Cannot copy table
> > > WARNING: Cannot copy ammprv at PERMANENT to current mapset as
> > > pat_ammprv
> > > 
> > > Yes, I know, that the user has to create this directory first. But
> > > this could also be done by the program.
> > > 
> > > So, where to apply a code modification:
> > > - db.connect - when using dbf driver?
> > > - g.copy/g.rename - when using dbf driver ?



Just to point out where this bites me: v.in.garmin creates a new vector
file with 'v.in.ascii type=standard'. It then makes a table with
db.execute:


v.in.ascii format=standard output="$NAME" input="${TMP}.dig"
echo "CREATE TABLE $NAME ($ATTR_COLS)" | db.execute

if its a new mapset with e.g., no dbf/ or VAR, you get this error:
ERROR: No db connection for driver <(null)> defined. Run db.connect


Understandable, but still not very nice for the end-user who just wants
it to be created automatically if it doesn't exist. Maybe db.execute is
a "raw" command so people using it must do so at their own
responsibility. 'v.in.ascii format=points' does create DB link/folder if
needed automatically, which is nice.

If I add in DB checking logic to v.in.garmin before trying to create a
table does it make everyone happy or does an issue still remain?

ie should
 db.connect driver=dbf database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'

make sure that '$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/' exists for the
driver=dbf case, as it will just mean a mkdir?

I still don't understand how db.connect sees database='$MAPSET' without
`eval g.gisenv` ... internal?



Hamish




More information about the grass-dev mailing list