diff flys-backend/contrib/shpimporter/utils.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 769593a84606
children c5187ab9f571
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/utils.py	Wed Feb 20 10:38:17 2013 +0100
+++ b/flys-backend/contrib/shpimporter/utils.py	Wed Feb 20 10:40:07 2013 +0100
@@ -11,6 +11,7 @@
 
 SHP='.shp'
 SQL_SELECT_RIVER_ID="SELECT id FROM rivers WHERE name = %s"
+SQL_SELECT_RIVER_ID_ORA="SELECT id FROM rivers WHERE name = :s"
 
 def findShapefiles(path):
     shapes = []
@@ -28,13 +29,19 @@
 
     return shapes
 
-def getRiverId(dbconn, name):
+def getRiverId(dbconn, name, oracle):
     """
     Returns the id of the river "name"
     Dbconn must be a python database connection api compliant object
     """
     cur = dbconn.cursor()
-    cur.execute(SQL_SELECT_RIVER_ID, (name,))
+    if oracle:
+        # This is stupid and shoudl not be neccessary. But I don't
+        # know how to make it work both ways. aheinecke - 02/2013
+        stmt = SQL_SELECT_RIVER_ID_ORA
+    else:
+        stmt = SQL_SELECT_RIVER_ID
+    cur.execute(stmt, (name,))
     row = cur.fetchone()
     if row:
         return row[0]

http://dive4elements.wald.intevation.org