Dear GRASS users,
I keep on getting SQLite driver errors when trying to use a newly created SQLite database (‘unable to open database’). By default, GRASS starts up connected to DBF. Connecting to an SQLite database works fine (when the database does not yet exist, it seems to create an empty database). So far so good. Problems emerge however when i next wish to import a shapefile, OR copy an attribute table from a shapefile that was previously imported using the DBF driver. I recall that an earlier version of GRASS 6.4 used SQLite as the default driver. With this version, all worked well, i.e. i did NOT have the problems described below.
Let me attach the command lines for both examples:
(1) Problem importing shapefile while connected to a SQLite database:
GRASS 6.4> db.connect driver=sqlite database=“c:\Test\sqlite.db”
GRASS 6.4> v.in.ogr dsn=C:\Test\pse.shp layer=pse output=pse
Datum <Palestine_1923> not recognised by GRASS and no parameters found
Projection of input dataset and current location appear to match
Layer: pse
DBMI-SQLite driver error:
Unable to open database: unable to open database file
Unable to open database <c:\test\sqlite.db> by driver
ERROR: Unable open database <c:\test\sqlite.db> by driver
(Fri May 06 13:33:01 2011) Command finished (0 sec)
(2) Problem copying attribute table (imported in DBF) to SQLite database):
GRASS 6.4> db.connect driver=sqlite database=“c:\Test\sqlite.db”
GRASS 6.4> g.copy vect=pse@pov4,pse_sqlite
Copy vector <pse@pov4> to current mapset as <pse_sqlite>
DBMI-SQLite driver error:
Unable to open database: unable to open database file
WARNING: Unable to open database by driver <c:\Test\sqlite.db>
no database is open
WARNING: Unable to copy table <pse_sqlite>
WARNING: Cannot copy <pse@pov4> to current mapset as <pse_sqlite>
(*) What am i doing wrong – What is the easiest way of fixing both of these problems??
Many thanks in advance,
Roy
Dear GRASS users,
I keep on getting SQLite driver errors when trying to use a newly created SQLite database (‘unable to open database’). By default, GRASS starts up connected to DBF. Connecting to an SQLite database works fine (when the database does not yet exist, it seems to create an empty database).
No I think that no database is created. It seems you have to do that manually, then the import and copy will work:
GRASS 6.4.0 (UTM36):~ > db.connect -p
driver:dbf
database:$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/
schema:
group:
GRASS 6.4.0 (UTM36):~ > eval
g.gisenv``
GRASS 6.4.0 (UTM36):~ > db.connect driv=sqlite database=$GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db
GRASS 6.4.0 (UTM36):~ > db.connect -p
driver:sqlite
database:/home/micha/geodata/grass/UTM36/Israel/geodata.db
schema:
group:
GRASS 6.4.0 (UTM36):~ > ll /home/micha/geodata/grass/UTM36/Israel/geodata.db
ls: cannot access /home/micha/geodata/grass/UTM36/Israel/geodata.db: No such file or directory
Note that no sqlite.db exists yet, so I do:
GRASS 6.4.0 (UTM36):~ > sqlite3 /home/micha/geodata/grass/UTM36/Israel/geodata.db
SQLite version 3.6.22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table temp (label varchar(16));
sqlite> .quit
GRASS 6.4.0 (UTM36):~ > ll /home/micha/geodata/grass/UTM36/Israel/geodata.db
-rw-r--r-- 1 micha micha 2048 2011-05-08 07:48 /home/micha/geodata/grass/UTM36/Israel/geodata.db
A minor annoyance, I guess. But if you think of sqlite as a database like PostgreSQL you wouldn’t expect GRASS to create a PostgreSQL database automatically …
···
--
Micha Silver
Arava Development Co. +972-52-3665918
[http://www.surfaces.co.il](http://www.surfaces.co.il)
Hi,
2011/5/8 Micha Silver <micha@arava.co.il>:
GRASS 6.4.0 (UTM36):~ > eval `g.gisenv`
GRASS 6.4.0 (UTM36):~ > db.connect driv=sqlite
database=$GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db
GRASS 6.4.0 (UTM36):~ > db.connect -p
driver:sqlite
database:/home/micha/geodata/grass/UTM36/Israel/geodata.db
schema:
group:
first of all, you don't need to run `g.gisenv`, just
$ db.connect driv=sqlite database='$GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db'
is enough.
GRASS 6.4.0 (UTM36):~ > ll /home/micha/geodata/grass/UTM36/Israel/geodata.db
ls: cannot access /home/micha/geodata/grass/UTM36/Israel/geodata.db: No such
file or directory
right, the database should be created when it's accessed.
After running eg. `g.copy`
$ eval `g.gisenv`
$ file $GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db
/home/martin/grassdata/nc_spm_08/landa6/geodata.db: SQLite 3.x database
The reported behaviour seems to be bug in winGRASS.
Martin
--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa
On 05/08/2011 12:29 PM, Martin Landa wrote:
Hi,
2011/5/8 Micha Silver<micha@arava.co.il>:
GRASS 6.4.0 (UTM36):~> eval `g.gisenv`
GRASS 6.4.0 (UTM36):~> db.connect driv=sqlite
database=$GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db
GRASS 6.4.0 (UTM36):~> db.connect -p
driver:sqlite
database:/home/micha/geodata/grass/UTM36/Israel/geodata.db
schema:
group:
first of all, you don't need to run `g.gisenv`, just
$ db.connect driv=sqlite database='$GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db'
is enough.
GRASS 6.4.0 (UTM36):~> ll /home/micha/geodata/grass/UTM36/Israel/geodata.db
ls: cannot access /home/micha/geodata/grass/UTM36/Israel/geodata.db: No such
file or directory
right, the database should be created when it's accessed.
After running eg. `g.copy`
$ eval `g.gisenv`
$ file $GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db
/home/martin/grassdata/nc_spm_08/landa6/geodata.db: SQLite 3.x database
The reported behaviour seems to be bug in winGRASS.
Martin
Thanks for clarifying
--
Micha
--
Micha Silver
Arava Development Co. +972-52-3665918
http://www.surfaces.co.il
Dear Micha and Martin,
Many thanks for your help.
Hope the bug in WinGRASS will soon be resolved.
Greetings,
Roy
-----Martin Landa landa.martin@gmail.com wrote: -----
To: Micha Silver micha@arava.co.il
From: Martin Landa landa.martin@gmail.com
Date: 05/08/2011 05:29AM
Cc: rvanderweide@worldbank.org, grass-user@lists.osgeo.org
Subject: Re: [GRASS-user] SQLite driver errors: `Unable to open database’
Hi,
2011/5/8 Micha Silver micha@arava.co.il:
GRASS 6.4.0 (UTM36):~ > eval g.gisenv
GRASS 6.4.0 (UTM36):~ > db.connect driv=sqlite
database=$GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db
GRASS 6.4.0 (UTM36):~ > db.connect -p
driver:sqlite
database:/home/micha/geodata/grass/UTM36/Israel/geodata.db
schema:
group:
first of all, you don’t need to run g.gisenv
, just
$ db.connect driv=sqlite database=‘$GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db’
is enough.
GRASS 6.4.0 (UTM36):~ > ll /home/micha/geodata/grass/UTM36/Israel/geodata.db
ls: cannot access /home/micha/geodata/grass/UTM36/Israel/geodata.db: No such
file or directory
right, the database should be created when it’s accessed.
After running eg. g.copy
$ eval g.gisenv
$ file $GISDBASE/$LOCATION_NAME/$MAPSET/geodata.db
/home/martin/grassdata/nc_spm_08/landa6/geodata.db: SQLite 3.x database
The reported behaviour seems to be bug in winGRASS.
Martin
–
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa
Hi,
2011/5/9 <rvanderweide@worldbank.org>:
Hope the bug in WinGRASS will soon be resolved.
please report it as trac ticket [1].
Martin
[1] https://trac.osgeo.org/grass/wiki/WikiStart#BugTracking
--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa