Opened 11 years ago

Closed 8 years ago

#2147 closed defect (fixed)

db.databases not working in GRASS 7

Reported by: cmbarton Owned by: grass-dev@…
Priority: normal Milestone: 7.0.5
Component: Database Version: svn-trunk
Keywords: db.databases, sqlite Cc:
CPU: OSX/Intel Platform: All

Description

I just discovered that db.databases is not working in GRASS 7. Other db.* modules seem to work OK.

db.databases location=nc_spm_08 driver=sqlite

dbmi: db_list_databases() not implemented
dbmi: db_list_databases() not implemented
ERROR: Unable to list databases

Not sure which exact version I have, but I built it 12 December 2013. I don't know what version because g.version is not returning the version number.

build_date=2013-12-12 libgis_revision=58048

Attachments (1)

listdb.c (4.3 KB ) - added by cmbarton 11 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by martinl, 11 years ago

Keywords: sqlite added

This is strange. Function which list databases has been implemented for SQLite driver 14 months ago (r53597). Do you have SQLite DB driver compiled?

db.driver -p

in reply to:  1 comment:2 by martinl, 11 years ago

Replying to martinl:

small typo in the last comment

db.drivers -p

in reply to:  1 ; comment:3 by cmbarton, 11 years ago

Replying to martinl:

This is strange. Function which list databases has been implemented for SQLite driver 14 months ago (r53597). Do you have SQLite DB driver compiled?

db.driver -p

Yes. SQLite works fine and shows up in the driver list

comment:4 by neteler, 11 years ago

Platform: UnspecifiedAll

Confirmed problem on Fedora 19:

# using older copy of NC dataset location:
GRASS 7.0.svn (nc_spm_08):~ > db.drivers -p
ogr
sqlite
dbf

GRASS 7.0.svn (nc_spm_08):~ > g.gisenv set=DEBUG=1
GRASS 7.0.svn (nc_spm_08):~ > db.databases 
D1/1: db_d_init_error(): DBF
dbmi: db_list_databases() not implemented
dbmi: db_list_databases() not implemented
ERROR: Unable to list databases

GRASS 7.0.svn (nc_spm_08):~ > db.connect -p
driver: dbf
database: /home/neteler/grassdata/nc_spm_08/user1/dbf/
schema: 
group: 

GRASS 7.0.svn (nc_spm_08):~ > db.connect -d
D1/1: Creating new default DB params with db_set_default_connection()
Default driver / database set to:
driver: sqlite
database: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db

GRASS 7.0.svn (nc_spm_08):~ > db.connect -p
driver: sqlite
database: /home/neteler/grassdata/nc_spm_08/user1/sqlite/sqlite.db
schema: 
group: 

GRASS 7.0.svn (nc_spm_08):~ > db.databases 
D1/1: db_d_init_error(): SQLite
D1/1: db count = 0
No databases found

in reply to:  4 ; comment:5 by martinl, 11 years ago

Replying to neteler:

> GRASS 7.0.svn (nc_spm_08):~ > db.databases 
> D1/1: db_d_init_error(): DBF
> dbmi: db_list_databases() not implemented
> dbmi: db_list_databases() not implemented
> ERROR: Unable to list databases
> 
> GRASS 7.0.svn (nc_spm_08):~ > db.connect -p
> driver: dbf
> database: /home/neteler/grassdata/nc_spm_08/user1/dbf/
> schema: 
> group: 

This is OK. DBF driver has no implemented function to list databases.

> GRASS 7.0.svn (nc_spm_08):~ > db.connect -d
> D1/1: Creating new default DB params with db_set_default_connection()
> Default driver / database set to:
> driver: sqlite
> database: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
> 
> GRASS 7.0.svn (nc_spm_08):~ > db.connect -p
> driver: sqlite
> database: /home/neteler/grassdata/nc_spm_08/user1/sqlite/sqlite.db
> schema: 
> group: 
> 
> GRASS 7.0.svn (nc_spm_08):~ > db.databases 
> D1/1: db_d_init_error(): SQLite
> D1/1: db count = 0
> No databases found

The command

db.connect -d
D1/1: Creating new default DB params with db_set_default_connection()
Default driver / database set to:
driver: sqlite
database: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db

doesn't create database, so db.databases doesn't list any database. You need to run command which writes attribute data to the database.

in reply to:  5 ; comment:6 by neteler, 11 years ago

Replying to martinl:

Replying to neteler:

...

> GRASS 7.0.svn (nc_spm_08):~ > db.databases 
> D1/1: db_d_init_error(): SQLite
> D1/1: db count = 0
> No databases found

The command

db.connect -d
D1/1: Creating new default DB params with db_set_default_connection()
Default driver / database set to:
driver: sqlite
database: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db

doesn't create database, so db.databases doesn't list any database. You need to run command which writes attribute data to the database.

Good point.

Maybe "db.connect -d" should create the (empty) sqlite.db file to avoid user confusion.

in reply to:  6 comment:7 by martinl, 11 years ago

Replying to neteler:

Maybe "db.connect -d" should create the (empty) sqlite.db file to avoid user confusion.

Probably, in any case it should be discussed in the separate ticket. In this case db.connect should behave similarly for all supported drivers, ie. to create directory for DBF driver, new empty database for SQLite or PostgreSQL drivers...

Martin

in reply to:  3 ; comment:8 by martinl, 11 years ago

Replying to cmbarton:

Yes. SQLite works fine and shows up in the driver list

It's strange, as I already mentioned, function to list databases has been implemented for SQLite driver 14 months ago. Please could you check source:grass/trunk/db/drivers/sqlite/listdb.c in your local source code tree.

by cmbarton, 11 years ago

Attachment: listdb.c added

in reply to:  8 comment:9 by cmbarton, 11 years ago

Replying to martinl:

Replying to cmbarton:

Yes. SQLite works fine and shows up in the driver list

It's strange, as I already mentioned, function to list databases has been implemented for SQLite driver 14 months ago. Please could you check source:grass/trunk/db/drivers/sqlite/listdb.c in your local source code tree.

It is attached:

comment:10 by wenzeslaus, 10 years ago

Is something mentioned here still an issue?

If unclear state of source code is the remaining issue (as suggested by last comments), please, check the file again. The best think to do is probably

cd db/drivers/sqlite
svn status

However, svn revert db/drivers/sqlite/listdb.c and svn up and also svn diff and svn info can be useful too.

comment:11 by cmbarton, 10 years ago

I just checked and the behavior is the same as I originally reported. I've run this from a mapset in my nc_spm_08 location that has a functioning SQLITE database. That is, this mapset has vectors connected to an SQLITE database that is working correctly. Yet I still get:

db.databases location=nc_spm_08nc_spm_08
dbmi: db_list_databases() not implemented
dbmi: db_list_databases() not implemented
ERROR: Unable to list databases. Try to define correct connection settings
       by db.login.

The manual defines "location" as follows:

"Default location for SQLite driver is the full path for the current mapset. For PostgreSQL driver it's empty connection string. "

This is NOT standard usage of the word "location" in GRASS. Nonetheless, it doesn't seem to work when I put in the proper pathname either.

db.databases location=$GISDBASE/$LOCATION_NAME/$MAPSET
dbmi: db_list_databases() not implemented
dbmi: db_list_databases() not implemented
ERROR: Unable to list databases. Try to define correct connection settings
       by db.login.

Same thing happens if I specify the path to the SQLite database itself:

db.databases location=$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
dbmi: db_list_databases() not implemented
dbmi: db_list_databases() not implemented
ERROR: Unable to list databases. Try to define correct connection settings
       by db.login.

Maybe the command is no longer relevant. If it doesn't work, maybe it should be dropped from the distribution.

comment:12 by martinl, 9 years ago

Milestone: 7.0.07.0.5

comment:13 by martinl, 8 years ago

Resolution: fixed
Status: newclosed

Tested with 7.0.5:

db.databases location=/opt/grassdata/piemonte/PERMANENT/sqlite/ driver=sqlite
/opt/grassdata/piemonte/PERMANENT/sqlite//sqlite.db

Closing.

Note: See TracTickets for help on using tickets.