diff flys-backend/contrib/shpimporter/importer.py @ 4871:890eaa0a5162

Add ogr_connection parameter to allow directly setting the ogr connection. This allows the importer to connect with all supported and not just OCI
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 23 Jan 2013 11:51:14 +0100
parents 82e931f88137
children a563e9f58f93
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/importer.py	Mon Jan 28 00:46:46 2013 +0100
+++ b/flys-backend/contrib/shpimporter/importer.py	Wed Jan 23 11:51:14 2013 +0100
@@ -5,7 +5,10 @@
 
     def __init__(self, config):
         self.config = config
-        self.dbconn   = 'OCI:%s/%s@%s' % (config.user, config.password, config.host)
+        if config.ogr_connection:
+            self.dbconn = '%s' % config.ogr_connection
+        else:
+            self.dbconn = 'OCI:%s/%s@%s' % (config.user, config.password, config.host)
         self.river_id = config.river_id
         self.dest_srs = osr.SpatialReference()
         self.dest_srs.ImportFromEPSG(config.target_srs)
@@ -84,6 +87,10 @@
 
     def shape2Database(self, srcLayer, name, path):
         table     = ogr.Open(self.dbconn)
+        if not table:
+            shpimporter.ERROR("Could not connect to database %s" % self.dbconn)
+            return -1
+
         destLayer = table.GetLayerByName(self.getTablename())
 
         if srcLayer is None:

http://dive4elements.wald.intevation.org