Mercurial > dive4elements > river
diff flys-backend/contrib/shpimporter/utils.py @ 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 | 174fbaa3d344 |
children | 998b29c8d2fd |
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]