[GRASSLIST:8931] db.copy fails with DBMI driver error

Hello all,

Hardware/Software:

5 Nov 2005 CVS binary of GRASS 6.x (Lorenzo Moretti) on Mac OS X (10.4).

Summary:

db.execute and db.copy fail while db.select and db.tables work. Any advice you may be able to give me on this problem would be much appreciated.

Problem:

I would like to use the command db.copy to transfer a table from a dbf database to a postgresql database. The db.copy command fails with the following error:

GRASS 6.1.cvs (engadin-swissgrid):~ > db.copy from_driver=dbf from_database=./ from_table=mapcodes2 to_driver=pg to_database="host=localhost,dbname=engadin" to_table=mapcodes2
DBMI-DBF driver error:
Table 'mapcodes2' doesn't exist.
Error in db_open_select_cursor()

WARNING: Cannot open select cursor: 'select * from mapcodes2 where 0 = 1'
WARNING: Copy table failed

A simpler command using db.execute also fails:

GRASS 6.1.cvs (engadin-swissgrid):~ > echo "select * from mapcodes" | db.execute
dbmi: Protocol error
ERROR: Error while executing: "select * from mapcodes
        "

However, this usage of db.tables -p works properly:

GRASS 6.1.cvs (engadin-swissgrid):~ > db.tables -p
eveg_cats2
eveg_cats3
eveg_cats4
eveg_cats5
mapcat
mapcodes
mapcodes2

And so does this usage of db.select:

GRASS 6.1.cvs (engadin-swissgrid):~ > echo "select * from mapcodes" | db.select

LEGCAT|MAPCODE|CEM_%|LAR_%|PIC_%|SYL_%|MUG_%|VIR_%|SAL_%|JUN_%|BET_%|INC_%|GRA_%|CYP_%
1|~|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000
2|..|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000
3|$|1.000000|1.000000|0.100000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|15.000000|3.000000
4|+|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|70.000000|20.000000
5|-|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|20.000000|70.000000
etc...

Thank you for your help!

Jed Kaplan

On Nov 8, 2005, at 4:24 AM, Jed O. Kaplan wrote:

GRASS 6.1.cvs (engadin-swissgrid):~ > db.copy from_driver=dbf from_database=./ from_table=mapcodes2 to_driver=pg to_database=“host=localhost,dbname=engadin” to_table=mapcodes2

DBMI-DBF driver error:

Table ‘mapcodes2’ doesn’t exist.

Did you try creating the table ‘mapcodes’ in postgres first before copying from dbf? Does anyone know if this is a required step?

Kirk

Error in db_open_select_cursor()

Kirk,

I had success by specifying the complete path to the DBF database in the from_database= argument instead of ./ as in the example in the man pages.

GRASS 6.1.cvs (engadin-swissgrid):~ > db.copy from_driver=dbf from_database='/Users/jkaplan/Documents/grass/engadin-swissgrid/PERMANENT/dbf/' from_table=mapcodes2 to_driver=pg to_database="host=localhost,dbname=engadin" to_table=mapcodes3

Seems to work!

Cheers,

Jed

On 10 Nov 2005, at 20:16, Kirk R. Wythers wrote:

On Nov 8, 2005, at 4:24 AM, Jed O. Kaplan wrote:

GRASS 6.1.cvs (engadin-swissgrid):~ > db.copy from_driver=dbf from_database=./ from_table=mapcodes2 to_driver=pg to_database="host=localhost,dbname=engadin" to_table=mapcodes2
DBMI-DBF driver error:
Table 'mapcodes2' doesn't exist.

Did you try creating the table 'mapcodes' in postgres first before copying from dbf? Does anyone know if this is a required step?

Kirk

Error in db_open_select_cursor()