comparison flys-backend/contrib/shpimporter/dgm.py @ 5267:9245f4b434b3

Fix syntax error in next_id and remove obsolete oracle parameter
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 13 Mar 2013 10:34:29 +0100
parents 8f71fe38977c
children 7d29c277000e
comparison
equal deleted inserted replaced
5266:de4c12b02374 5267:9245f4b434b3
56 """ 56 """
57 SQL_NEXT_ID = "SELECT coalesce(max(id), -1) + 1 FROM %s" 57 SQL_NEXT_ID = "SELECT coalesce(max(id), -1) + 1 FROM %s"
58 58
59 59
60 NEXT_IDS = {} 60 NEXT_IDS = {}
61 def next_id(cur, relation, oracle): 61 def next_id(cur, relation):
62 idx = NEXT_IDS.get(relation) 62 idx = NEXT_IDS.get(relation)
63 if idx is None: 63 if idx is None:
64 cur.execute(SQL_NEXT_ID % relation) 64 cur.execute(SQL_NEXT_ID % relation)
65 idx = cur.fetchone()[0] 65 idx = cur.fetchone()[0]
66 NEXT_IDS[relation] = idx + 1 66 NEXT_IDS[relation] = idx + 1
67 return idx 67 return idx
68 68
69 def get_range_id(cur, river_id, a, b, oracle): 69 def get_range_id(cur, river_id, a, b, oracle):
71 cur.execute(SQL_SELECT_RANGE_ID_ORA, (river_id, a, b)) 71 cur.execute(SQL_SELECT_RANGE_ID_ORA, (river_id, a, b))
72 else: 72 else:
73 cur.execute(SQL_SELECT_RANGE_ID, (river_id, a, b)) 73 cur.execute(SQL_SELECT_RANGE_ID, (river_id, a, b))
74 row = cur.fetchone() 74 row = cur.fetchone()
75 if row: return row[0] 75 if row: return row[0]
76 idx = next_id(cur, "ranges", oracle) 76 idx = next_id(cur, "ranges")
77 if oracle: 77 if oracle:
78 cur.execute(SQL_INSERT_RANGE_ID_ORA, (idx, river_id, a, b)) 78 cur.execute(SQL_INSERT_RANGE_ID_ORA, (idx, river_id, a, b))
79 else: 79 else:
80 cur.execute(SQL_INSERT_RANGE_ID, (idx, river_id, a, b)) 80 cur.execute(SQL_INSERT_RANGE_ID, (idx, river_id, a, b))
81 cur.connection.commit() 81 cur.connection.commit()
88 cur.execute(SQL_SELECT_TIME_ID_ORA, (a, b)) 88 cur.execute(SQL_SELECT_TIME_ID_ORA, (a, b))
89 else: 89 else:
90 cur.execute(SQL_SELECT_TIME_ID, (a, b)) 90 cur.execute(SQL_SELECT_TIME_ID, (a, b))
91 row = cur.fetchone() 91 row = cur.fetchone()
92 if row: return row[0] 92 if row: return row[0]
93 idx = next_id(cur, "time_intervals", oracle) 93 idx = next_id(cur, "time_intervals")
94 if oracle: 94 if oracle:
95 cur.execute(SQL_INSERT_TIME_ID_ORA, (idx, a, b)) 95 cur.execute(SQL_INSERT_TIME_ID_ORA, (idx, a, b))
96 else: 96 else:
97 cur.execute(SQL_INSERT_TIME_ID, (idx, a, b)) 97 cur.execute(SQL_INSERT_TIME_ID, (idx, a, b))
98 cur.connection.commit() 98 cur.connection.commit()

http://dive4elements.wald.intevation.org