changeset 4976:a6ee62a070b0 dami

I'm learning how to use cursors \o/
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 13 Feb 2013 17:49:30 +0100
parents 9eea3cd22ee7
children ee908e4946cd
files flys-backend/contrib/shpimporter/utils.py
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/utils.py	Wed Feb 13 17:46:34 2013 +0100
+++ b/flys-backend/contrib/shpimporter/utils.py	Wed Feb 13 17:49:30 2013 +0100
@@ -7,7 +7,7 @@
     import ogr
 
 SHP='.shp'
-SQL_SELECT_ID="SELECT id FROM %s WHERE %s = '%s'"
+SQL_SELECT_RIVER_ID="SELECT id FROM rivers WHERE name = %s"
 
 def findShapefiles(path):
     shapes = []
@@ -31,8 +31,7 @@
     Dbconn must be a python database connection api compliant object
     """
     cur = dbconn.cursor()
-    select_stmt = SQL_SELECT_ID % ("rivers", "name", name)
-    cur.execute(select_stmt)
+    cur.execute(SQL_SELECT_RIVER_ID, (name,))
     row = cur.fetchone()
     if row:
         return row[0]

http://dive4elements.wald.intevation.org