diff flys-backend/contrib/shpimporter/shpimporter.py @ 5036:d6860fca89e4 dami

Pull information about the backend into dgm. While the api of cx_oracle and psycopg2 is compatible enough, the query syntax is not :(
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 20 Feb 2013 10:40:07 +0100
parents a5f438895a38
children c5187ab9f571
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/shpimporter.py	Wed Feb 20 10:38:17 2013 +0100
+++ b/flys-backend/contrib/shpimporter/shpimporter.py	Wed Feb 20 10:40:07 2013 +0100
@@ -145,7 +145,9 @@
     else:
         connstr = 'OCI:%s/%s@%s' % (config.user, config.password, config.host)
 
+    oracle = False # Marker if oracle is used.
     if 'OCI:' in connstr:
+        oracle = True
         try:
             import cx_Oracle as dbapi
             raw_connstr=connstr.replace("OCI:", "")
@@ -154,6 +156,7 @@
                   "Neccessary to connect to a Oracle Database.\n"
                   "Please refer to the installation "
                   "documentation." % sys.path)
+            return -1
 
     else: # Currently only support for oracle and postgres
         try:
@@ -164,6 +167,7 @@
                   "Neccessary to connect to a Posgresql Database.\n"
                   "Please refer to the installation "
                   "documentation." % sys.path)
+            return -1
 
     dbconn_raw = dbapi.connect(raw_connstr)
     dbconn = ogr.Open(connstr)
@@ -189,7 +193,7 @@
                     os.path.basename(os.path.normpath(directory)))
         else:
             river_name = config.river_name
-        river_id = utils.getRiverId(dbconn_raw, river_name)
+        river_id = utils.getRiverId(dbconn_raw, river_name, oracle)
 
         if not river_id:
             logger.info("Could not find river in database. Skipping: %s"
@@ -229,7 +233,8 @@
                      "Skipping DGM import." % dgmfilename)
             else:
                 logger.info("Inserting DGM meta information in 'dem' table.")
-                insertRiverDgm(dbconn_raw, dgmfilename, river_name, config.dry_run)
+                insertRiverDgm(dbconn_raw, dgmfilename, river_name,
+                        config.dry_run, oracle)
         else:
             logger.info("Skip import of DGM.")
 

http://dive4elements.wald.intevation.org