summaryrefslogtreecommitdiff
path: root/opendc/models/machine.py
diff options
context:
space:
mode:
authorGeorgios Andreadis <G.Andreadis@student.tudelft.nl>2017-08-10 09:40:26 +0300
committerGitHub <noreply@github.com>2017-08-10 09:40:26 +0300
commitbc70e6ae115beb469541c12014ffdecc01a1e50c (patch)
tree935c2ef5b1621b0e13ec76f2ca02f6912940d690 /opendc/models/machine.py
parent5d42f30ed30aa5b6970304569c6bd01c16078759 (diff)
parent54617bf3268c27d63a40844216760a49f28d39e0 (diff)
Merge pull request #9 from atlarge-research/mariadb
Migration to MariaDB
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 52cf221b..a2b7f57d 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 = []