summaryrefslogtreecommitdiff
path: root/opendc/models/machine.py
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-08-13 23:17:50 +0300
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-08-13 23:17:50 +0300
commit3d086d18a2639a76c4739b6ca7ca06416356c706 (patch)
tree5c9e122ae7e84b8013e8a742714a5779f871f6ad /opendc/models/machine.py
parentf589682b0840aab0624122052eb863cf8dc3a0b9 (diff)
parentbc70e6ae115beb469541c12014ffdecc01a1e50c (diff)
Merge branch 'master' into flat-api
Diffstat (limited to 'opendc/models/machine.py')
-rw-r--r--opendc/models/machine.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/opendc/models/machine.py b/opendc/models/machine.py
index 54838ffd..90945ef1 100644
--- a/opendc/models/machine.py
+++ b/opendc/models/machine.py
@@ -44,14 +44,14 @@ class Machine(Model):
# First, delete current machine-device links
- statement = 'DELETE FROM machine_{} WHERE machine_id = ?'.format(device_table)
+ statement = 'DELETE FROM machine_{} WHERE machine_id = %s'.format(device_table)
database.execute(statement, (before_insert.id,))
# Then, add current ones
for device_id in getattr(before_insert, before_insert.device_table_to_attribute[device_table]):
- statement = 'INSERT INTO machine_{} (machine_id, {}) VALUES (?, ?)'.format(
+ statement = 'INSERT INTO machine_{} (machine_id, {}) VALUES (%s, %s)'.format(
device_table,
before_insert.device_table_to_attribute[device_table][:-1]
)
@@ -68,7 +68,7 @@ class Machine(Model):
return cls(id = -1)
try:
- statement = 'SELECT id FROM machines WHERE rack_id = ? AND position = ?'
+ statement = 'SELECT id FROM machines WHERE rack_id = %s AND position = %s'
machine_id = database.fetchone(statement, (rack.id, position))[0]
except:
return cls(id = -1)
@@ -106,7 +106,7 @@ class Machine(Model):
for device_table in self.device_table_to_attribute.keys():
- statement = 'SELECT * FROM machine_{} WHERE machine_id = ?'.format(device_table)
+ statement = 'SELECT * FROM machine_{} WHERE machine_id = %s'.format(device_table)
results = database.fetchall(statement, (self.id,))
device_ids = []