This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

duplicate key value violates unique constraint “relations_pkey”

0

When i use osmosis command to import data into the openstreetmap database, some error appears, such as duplicate key value violates unique constraint "relations_pkey". The command that i used is ./osmosis-latest/bin/osmosis --read-pbf file="planet/chengdu_china.osm.pbf" --write-apidb host="localhost" database="openstreetmap" user="osm" password="buaanlp" validateSchemaVersion=no. I have used the lastest osmosis tool and the version of osmosis is 0.45, but the problem still arise, how can i sovle this problem?

If this problem can't be solved, then how can i add .pdf data file into the apidb?

asked 12 Sep '16, 05:15

yuyy's gravatar image

yuyy
236222431
accept rate: 20%


One Answer:

1

The key to the answer is in your last sentence: you are adding data to an existing datanase, which already contains an entry for the objects in question.

AFAIK you cannot directly merge into an existing APIDB with osmosis, you can however merge two datasources into one, see --merge. With other words you should pre-merge and then import (if you have modified data in your APIDB likely export, merge, re-import).

answered 12 Sep '16, 11:49

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701
accept rate: 18%

Ok,thanks to your reply, so the osmosis command only can use once when import .pbf data file because the apidb must keep empty, this is so unconvenient and unreasonable.

(12 Sep '16, 12:44) yuyy

Source code available on GitHub .