[GRASS-user] database(s) in grass

Markus Neteler neteler at itc.it
Wed Apr 11 14:20:26 EDT 2007


Ricardo,

On Wed, Apr 11, 2007 at 06:49:37PM +0100, Ricardo Oliveira wrote:
>    Dear users,
>    Being a recent GRASS user i am facing some problems with databases: i am
>    using v.digit and after finishing a boundary i get the following error:
>    ============================================
>    D0/0: Name = cat
>    D0/0: Name = _grass_internal_database_encoding
>    D0/0: Name = _grass_internal_database_encoding
>    Could not set Tcl system encoding to
>    D0/0: Name = _grass_internal_database_encoding
>    Could not set Tcl system encoding to
>    D0/0: Name = _grass_internal_database_encoding
>    Could not set Tcl system encoding to
>    DBMI-SQLite driver error:
>    Error in sqlite3_prepare():
>    near "where": syntax error
> 
>    Cannot update table

I assume that your table is lacking an integer column "cat".
Please tell us how you launched the v.digit command.

Unrelated:
The _grass_internal_database_encoding was fixed recently, it now
depends on this GRASS version you use.

>    ============================================
> 
>    I am using the sqlite driver, and i have used the following commands to
>    build and connect to my database:
>    sqlite3 basedados.db
>    create table name (id varchar(10), cat smallint, feature smallint);
>    EOF
>    db.connect driver=sqlite database="basedados.db"
>    db.connect -p

Please specify also the path to basedados.db.

Generally you don't need to generate the basedados.db database if you
want to create a new map - GRASS will do this for you. It is best to
follow this approach:

# example for storing DB in mapset directory (keep single quotes):
db.connect driver=sqlite database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db'
db.connect -p

This will put the file sqlite.db (or however you name it) into
the related mapset directory. The single quotes prevent from expanding
the variable names. GRASS internally substitutes these variables to
the correct path (which you can verify with g.gisenv).

>    I am a complete newby in terms of databases...when browsing my table with
>    sqlitebrowser i am able to find IDs on the table i have created inside
>    v.digit, (1,2,3...) these IDs are related to the entities i digitized i
>    assume...but shouldn`t the coordinates have their column  on this database
>    too (at least for the centroid...) ?
> 
>    Tips are needed for the error and for my questions...
>    Thanks

Suggestion:

1. do

# example for storing DB in mapset directory (keep single quotes):
db.connect driver=sqlite database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db'
db.connect -p


2. do

v.digit -n newmap

Then go into the settings dialog and define the table columns.
This will create in this moment to sqlite database file and the
new table linked to 'newmap'. Then digitize...

hope this helps,
Markus




More information about the grass-user mailing list