[Dive4elements-commits] [PATCH 3 of 3] I'm learning how to use cursors \o/
Wald Commits
scm-commit at wald.intevation.org
Wed Feb 13 17:49:56 CET 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1360774170 -3600
# Branch dami
# Node ID a6ee62a070b0c9f53e1319a7dd875baded9a0099
# Parent 9eea3cd22ee7262a09d04522d3665250167c5abd
I'm learning how to use cursors \o/
diff -r 9eea3cd22ee7 -r a6ee62a070b0 flys-backend/contrib/shpimporter/utils.py
--- 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]
More information about the Dive4elements-commits
mailing list