[GRASSLIST:3622] Re: Disconnecting db in 5.7
Radim Blazek
blazek at itc.it
Tue Jun 8 08:40:39 EDT 2004
On Monday 07 June 2004 22:50, Craig Aumann wrote:
> A few days ago, I ran an overlay command and then linked the output up
> to an attribute table:
>
> v.overlay ainput=l1ashp atype=area binput=curregion btype=area
> output=l1ashp2cut operator=and
It was output=l1ashpcut, I presume?
> v.db.connect -o map=l1ashpcut table=l1aatt key=LINK_KEY \
> driver=pg database="dbname=jogis,user=caumann"
>
>
> Today, I tried to re-run things and got the following error:
>
> GRASS 5.7.-cvs:~/grass57/netdown/jogis/caumann/vector > v.overlay
> ainput=l1ashp atype=area binput=curregion btype=area output=l1ashpcut \
>
> > operator=and
>
> ---------------------------------------------------------------------------
>-- Writing attributes ...
> DBMI-DBF driver error:
> Table l1ashpcut already exists
> Error in db_execute_immediate()
>
> ERROR: Cannot create table: create table l1ashpcut (cat integer, cata
> integer, catb integer)
>
> --------------
>
> No matter what I do, I can't make this error go away. I suspect I
> should have done something to disconnect the db before I re-ran this.
>
> What am I not understanding/not doing right?
v.db.connect must be used with attention and understanding what it does.
In general it creates/deletes links to tables, but doe not create/drop/copy
the table.
v.overlay created a new table 'l1ashpcut' linked to field 1,
then you relinked the field 1 (v.db.connect -o map=l1ashpcut table=l1aatt),
to the table 'l1aatt', the table 'l1ashpcut' however remains in the database.
When you run 'v.overlay output=l1ashpcut' second time, it first deletes
old existing vector 'l1ashpcut' and all its tables (in this case only
the table 'l1aatt', which you linked by v.db.connect).
The table 'l1ashpcut' was not deleted because the link to this table
was overwritten by 'v.db.connect -o' so the vector 'l1ashpcut' knows
nothing about that table.
You have to run something like
echo 'drop table l1ashpcut' | db.execute
for example, to delete the table.
Radim
More information about the grass-user
mailing list