[OSM-dev] Problem populating rails database with planetosm-to-db.pl

Robert (Jamie) Munro rjmunro at arjam.net
Sun May 20 12:39:58 BST 2007

Hash: SHA1

Nick Whitelegg wrote:
> Just tried populating the rails database using planetosm-to-db.pl.
> It fails when it starts adding ways:
> DBD::mysql::st execute failed: Duplicate entry '126' for key 1 
> at ./planetosm-to-db.pl line 352, <XML> line 209509.
> Should 'id' and 'version' actually be primary keys? 

It's not that they are primary keys, it's that together they form /the/
primary key. And yes, they should be.

That error shouldn't be happening on that table because sequence_id is
part of the key, and it is auto-generated, so can't have the same value
twice. Also MySQL will normally report all the parts of the key that are
duplicate, something like Duplicate entry (123,2435,45645) for key.

> I tried stopping 'id' 
> being a primary key but then it complained about duplicate entries for 
> 'version'.

It would. That will make it worse because the primary key is shorter.

> Can I get away with removing all these primary key definitions 
> i.e. will I have a working Potlatch by doing so? (Don't want to waste my time 
> with fruitless experiments....)

It will probably work, but you may just be hiding another problem that
is causing lots of duplicate data that you don't want. You could try
changing the perl to log the errors and carry on, rather than abort, and
see how many errors you are getting, or you could try modifing the
python script written for the PostGIS port here:

to use MySQLdb instead of psycopg2.

Robert (Jamie) Munro
Version: GnuPG v1.4.6 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the dev mailing list