[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


-----BEGIN PGP SIGNED MESSAGE-----
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:
http://svn.openstreetmap.org/sites/rails_port_postgis_branch/db/import_osm.py

to use MySQLdb instead of psycopg2.

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

iD8DBQFGUDOLz+aYVHdncI0RAgheAKDEnPpaG1UB5AXN7x9qfdgcjk0DVgCeJMBG
SY1UZ0J7jjg0upo56226Wd8=
=U0ie
-----END PGP SIGNATURE-----




More information about the dev mailing list