[GRASS-user] sqlite database connection problems

Johannes Radinger JRadinger at gmx.at
Tue May 17 10:39:31 EDT 2011


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

> On Tue, May 17, 2011 at 2:01 PM, Johannes Radinger <JRadinger at gmx.at>
> wrote:
> > Hello,
> >
> > I tried to delete a vector file but I got following error:
> >
> > g.remove vect=river_gen at Cele
> > Removing vector <river_gen at 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


More information about the grass-user mailing list