[GRASS-dev] Separate sqlite database files for vector maps

Markus Metz markus.metz.giswork at gmail.com
Sun Sep 11 12:28:47 PDT 2016


On Sat, Sep 10, 2016 at 11:24 PM, Sören Gebbert
<soerengebbert at googlemail.com> wrote:
> Mi Markus,
>
> [snip]
>>
>>
>> Essentially, all that is needed is a corresponding entry in
>> $LOCATION_NAME/VAR:
>> instead of
>> DB_DRIVER: sqlite
>> DB_DATABASE: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
>>
>> try
>> DB_DATABASE: $GISDBASE/$LOCATION_NAME/$MAPSET/vector/$MAP/sqlite/sqlite.db
>>
>> HTH,
>
>
> This helped a lot, thank you. Simply running:
> db.connect driver=sqlite
> database='$GISDBASE/$LOCATION_NAME/$MAPSET/vector/$MAP/sqlite.db'
>
> will do the job. This can be run right after mapset creation.
>
> And it works nicely. It seems that most of the v.db.* commands work with
> vector map specific database files. The db.* commands seemed work as well,
> if the database path is provided at the command line.
>
> I skipped the sqlite directory in the vector map path ($MAP/sqlite/sqlite.db
> -> $MAP/sqlite.db), since this directory must be created when a new vector
> is opened, hence the vector-open-new functions must be modified to support a
> separate sqlite directory. With the simple solution the directory fsync()
> behavior of sqlite will force now all vector map specific files to be
> flushed to disc. This may be a performance problem.

sqlite might not open the (new) database at all if it can not fsync()
the directory. That will not result in performance penalty but in a
fatal error, therefore it is a good idea to keep the sqlite db in a
separate folder.

The GRASS sqlite driver attempts to create the sqlite directory
(db__driver_open_database() in trunk/db/driver/sqlite/db.c) if the
directory does not exist, therefore Vect_open_new*() should not need
any modification.

>
> This solution may be sufficient for my needs, no modification needed in the
> code ... except, v.info should show the database path of a vector map if
> extended metadata is required.
>
>
> Many thanks for your help
> Best regards
> Soeren
>
>>
>>
>> Markus M
>
>


More information about the grass-dev mailing list