Skip to content

Commit

Permalink
Allow for more than 3 points to be added in the insert statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
cchristelis committed Jun 19, 2014
1 parent b400204 commit cda918c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"AVAILABLE":"SELECT available FROM parcel_lookup WHERE parcel_id = %s;",
"INSERT":"INSERT INTO parcel_def(parcel_id, beacon, sequence) \
VALUES (%s, %s, %s);",
"INSERT_GENERAL": "INSERT INTO parcel_def(parcel_id, beacon, sequence) \
VALUES %s;",
"DELETE":"DELETE FROM parcel_def WHERE parcel_id = %s;",
}

Expand Down
3 changes: 2 additions & 1 deletion database.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ def queryPreview(self, query, data=None, multi_data=False):
sql = self.cursor.mogrify(query)
else:
if multi_data:
placeholders = ','.join(['%s' for dummy in data])
query = query % (placeholders)
sql = self.cursor.mogrify(query, data)
sql = sql.replace('((', '(').replace('))', ')')
else:
sql = self.cursor.mogrify(query, data)
self.disconnect()
Expand Down
3 changes: 1 addition & 2 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,10 @@ def run(self):
points.append(
(frm.getValues()[1]["parcel_id"], beacon, i))
sql = self.db.queryPreview(
SQL_PARCELS["INSERT"],
SQL_PARCELS["INSERT_GENERAL"],
data=points,
multi_data=True
)
print sql
self.db.query(sql)
self.iface.mapCanvas().refresh()
else:
Expand Down

0 comments on commit cda918c

Please sign in to comment.