[GRASS-user] sqlite database connection problems

Hello,

I tried to delete a vector file but I got following error:

g.remove vect=river_gen@Cele
Removing vector <river_gen@Cele>
DBMI-SQLite driver error:
Unable to open database: unable to open database file
Unable to open database </Users/Johannes Radinger/Documents/GRASS-GIS/Cele_location/Cele/sqlite.db/> by driver <sqlite>
Unable open database </Users/Johannes Radinger/Documents/GRASS-GIS/Cele_location/Cele/sqlite.db/> by driver <sqlite>
Unable to find table <river_gen> linked to vector map <river_gen>
couldn't be removed
<river_gen> nothing removed

So i tried to list the the database connection and tables of my database and but there is that table existing:

db.connect -p
driver:sqlite
database:$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db/
schema:
group:

db.tables -p
river_gen

I am using Grass 6.5SVN (around 2 weeks old) on mac os x. What is causing this connection problem??

thank you

/johannes
--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone

On Tue, May 17, 2011 at 2:01 PM, Johannes Radinger <JRadinger@gmx.at> wrote:

Hello,

I tried to delete a vector file but I got following error:

g.remove vect=river_gen@Cele
Removing vector <river_gen@Cele>
DBMI-SQLite driver error:
Unable to open database: unable to open database file
Unable to open database </Users/Johannes Radinger/Documents/GRASS-GIS/Cele_location/Cele/sqlite.db/> by driver <sqlite>

The trailing slash at sqlite.db/ should not be there.

...

So i tried to list the the database connection and tables of my database and but there is that table existing:

db.connect -p
driver:sqlite
database:$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db/

sqlite.db is a file, with / triling GRASS may think that this indicates a
directory.

You need to define the DB link properly. That is in the VAR
file in the mapset (ASCII file) as well as in the dbln file of the
vector map - you can easily fix that with a text editor.
Be sure to avoid the trailing slash in future for the SQLite
backend, see manual of the grass-sqlite driver.

Markus

-------- Original-Nachricht --------

Datum: Tue, 17 May 2011 15:50:51 +0200
Von: Markus Neteler <neteler@osgeo.org>
An: Johannes Radinger <JRadinger@gmx.at>
CC: GRASS user list <grass-user@lists.osgeo.org>
Betreff: Re: [GRASS-user] sqlite database connection problems

On Tue, May 17, 2011 at 2:01 PM, Johannes Radinger <JRadinger@gmx.at>
wrote:
> Hello,
>
> I tried to delete a vector file but I got following error:
>
> g.remove vect=river_gen@Cele
> Removing vector <river_gen@Cele>
> DBMI-SQLite driver error:
> Unable to open database: unable to open database file
> Unable to open database </Users/Johannes
Radinger/Documents/GRASS-GIS/Cele_location/Cele/sqlite.db/> by driver <sqlite>

The trailing slash at sqlite.db/ should not be there.

...
> So i tried to list the the database connection and tables of my database
and but there is that table existing:
>
> db.connect -p
> driver:sqlite
> database:$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db/

sqlite.db is a file, with / triling GRASS may think that this indicates a
directory.

You need to define the DB link properly. That is in the VAR
file in the mapset (ASCII file) as well as in the dbln file of the
vector map - you can easily fix that with a text editor.
Be sure to avoid the trailing slash in future for the SQLite
backend, see manual of the grass-sqlite driver.

Oh I didn't recognize the trailing slash.

But there are still some problems/questions I've got with sqlite database.
I created a totally new mapset (no sqlite database existing in the beginning) and then I tried following script:

    input_barriers = options['barriers']

    env = grass.gisenv()

    gisdbase = env['GISDBASE']
    location = env['LOCATION_NAME']
    mapset = env['MAPSET']

    grass.run_command("db.connect",
                      driver = "sqlite",
                      database = os.path.join(gisdbase,location,mapset,'sqlite.db'),
                      flags = "c")

    grass.run_command("v.in.ascii",
                      flags = "n",
                      overwrite = True,
                      input=input_barriers,
                      output="barriers",
                      skip=1,
                      columns="x DOUBLE, y DOUBLE, clearance DOUBLE")

Is there now a table in the sqlite database created or not? I don't think so (checked with the SQlite Manager), but if I try grass.run_command("v.db.addtable", map="barriers") it says there is already a table linked to it. Is there a link to the old default database although the sqlite database was set before?

/Johannes

Markus

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone

-------- Original-Nachricht --------

Datum: Tue, 17 May 2011 16:39:31 +0200
Von: "Johannes Radinger" <JRadinger@gmx.at>
An: Markus Neteler <neteler@osgeo.org>
CC: grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] sqlite database connection problems

-------- Original-Nachricht --------
> Datum: Tue, 17 May 2011 15:50:51 +0200
> Von: Markus Neteler <neteler@osgeo.org>
> An: Johannes Radinger <JRadinger@gmx.at>
> CC: GRASS user list <grass-user@lists.osgeo.org>
> Betreff: Re: [GRASS-user] sqlite database connection problems

> On Tue, May 17, 2011 at 2:01 PM, Johannes Radinger <JRadinger@gmx.at>
> wrote:
> > Hello,
> >
> > I tried to delete a vector file but I got following error:
> >
> > g.remove vect=river_gen@Cele
> > Removing vector <river_gen@Cele>
> > DBMI-SQLite driver error:
> > Unable to open database: unable to open database file
> > Unable to open database </Users/Johannes
> Radinger/Documents/GRASS-GIS/Cele_location/Cele/sqlite.db/> by driver
<sqlite>
>
> The trailing slash at sqlite.db/ should not be there.
>
> ...
> > So i tried to list the the database connection and tables of my
database
> and but there is that table existing:
> >
> > db.connect -p
> > driver:sqlite
> > database:$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db/
>
> sqlite.db is a file, with / triling GRASS may think that this indicates
a
> directory.
>
> You need to define the DB link properly. That is in the VAR
> file in the mapset (ASCII file) as well as in the dbln file of the
> vector map - you can easily fix that with a text editor.
> Be sure to avoid the trailing slash in future for the SQLite
> backend, see manual of the grass-sqlite driver.

Oh I didn't recognize the trailing slash.

But there are still some problems/questions I've got with sqlite database.
I created a totally new mapset (no sqlite database existing in the
beginning) and then I tried following script:

    input_barriers = options['barriers']

    env = grass.gisenv()

    gisdbase = env['GISDBASE']
    location = env['LOCATION_NAME']
    mapset = env['MAPSET']

    grass.run_command("db.connect",
                      driver = "sqlite",
                      database =
os.path.join(gisdbase,location,mapset,'sqlite.db'),
                      flags = "c")

    grass.run_command("v.in.ascii",
                      flags = "n",
                      overwrite = True,
                      input=input_barriers,
                      output="barriers",
                      skip=1,
                      columns="x DOUBLE, y DOUBLE, clearance DOUBLE")

Is there now a table in the sqlite database created or not? I don't think
so (checked with the SQlite Manager), but if I try
grass.run_command("v.db.addtable", map="barriers") it says there is already a table linked to it.
Is there a link to the old default database although the sqlite database was
set before?

It seems that I found the problem. It is the c flag in db.connect. The manual says "Check connection parameters, set if uninitialized, and exit" and uninitialized means probably totally uninitialized. So the connection isn't set to e.g sqlite if already a dbf connection exists when the c-flag is set.

/johannes

/Johannes

>
> Markus

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
Ihr GMX Postfach immer dabei: die kostenlose GMX Mail App für Android.
Komfortabel, sicher und schnell: www.gmx.de/android