0

I have a problem with osm2pgsql when it runs in a qgis plugin. The function i use looks like this:

    osm2pgsql = "osm2pgsql -s -d {databaseName} -U {databaseUser} -H {databaseHost} -E {SRID_GEOMETRY} {osm_file}"\
        .format(databaseName=connParam[0],
                databaseUser=connParam[2],
                databaseHost=connParam[1],
                SRID_GEOMETRY=srid,
                osm_file=down_file)

    os.system(osm2pgsql)

When i run this function in the python console in QGIS it runs without a problem. But when this function is used in a plugin it doesent't work. The osm2pgsql function starts with the console output

 Using projection SRS 32632 (EPSG:32632)
 Setting up table: planet_osm_point

but then nothing happens and qgis freezes. When I close qgis the function starts running and finishes successfully.

Has anyone an idea why this happens?

  • Osm2pgsql requires a lot of CPU, RAM and temporary disk space. Can you control how much is available for the plugin? And whether it can open temporary files? – AndreJ Oct 21 '14 at 7:51
  • The osm file I use has a size of only 10 MB. The strange thing is that if i load it as a script it runs in ~10 sec successfully. – Martin Oct 21 '14 at 7:54
3

I just found a solution.

There is also an active psycop2 connection. When I commit it or close the connection before osm2pgsql runs and open it afterwards again it works. Probably osm2pgsql can't access to the database if this connection is open.

  • 1
    That makes sense. osm2pgsql changes/deletes the database tables too. This might be blocked if another connection exists. – AndreJ Oct 21 '14 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.