Add quotes around values in INSERT statements
Change-Id: Icb7fedf8c77e8d23e62118d20740f4ec86be5cf2
diff --git a/db/db.py b/db/db.py
index 5089f36..2fb3dfd 100644
--- a/db/db.py
+++ b/db/db.py
@@ -36,8 +36,8 @@
def create_switch(self, name, admin_password, cli_password):
try:
- self.cursor("INSERT INTO switch (name, admin_pw, cli_pw) VALUES (%s, %s, %s) RETURNING switch_id" %
- (name, admin_password, cli_password))
+ self.cursor.execute("INSERT INTO switch (name, admin_pw, cli_pw) VALUES ('%s', '%s', '%s') RETURNING switch_id" %
+ (name, admin_password, cli_password))
switch_id = self.cursor.fetchone()[0]
self.connection.commit()
except:
@@ -47,8 +47,8 @@
def create_port(self, name, switch_id, is_locked, is_trunk, current_vlan_id, base_vlan_id):
try:
- self.cursor("INSERT INTO port (name, switch_id, is_locked, is_trunk, current_vlan_id, base_vlan_id)"
- "VALUES (%s, %s, %s %s %s %s) RETURNING port_id" %
+ self.cursor.execute("INSERT INTO port (name, switch_id, is_locked, is_trunk, current_vlan_id, base_vlan_id)"
+ "VALUES ('%s', '%s', '%s', '%s', '%s', '%s') RETURNING port_id" %
(name, switch_id, is_locked, is_trunk, current_vlan_id, base_vlan_id))
port_id = self.cursor.fetchone()[0]
self.connection.commit()
@@ -59,8 +59,8 @@
def create_vlan(self, name, tag, is_default_vlan):
try:
- self.cursor("INSERT INTO vlan (name, tag, is_default_vlan)"
- "VALUES (%s, %s, %s) RETURNING vlan_id" %
+ self.cursor.execute("INSERT INTO vlan (name, tag, is_default_vlan)"
+ "VALUES ('%s', '%s', '%s') RETURNING vlan_id" %
(name, tag, is_default_vlan))
vlan_id = self.cursor.fetchone()[0]
self.connection.commit()