Index: bitten/model.py
===================================================================
--- bitten/model.py	(revision 561)
+++ bitten/model.py	(working copy)
@@ -217,8 +217,8 @@
             handle_ta = False
 
         cursor = db.cursor()
-        cursor.execute("DELETE FROM bitten_rule WHERE id=%s", (self.id,))
-        cursor.execute("DELETE FROM bitten_platform WHERE id=%s", (self.id,))
+        cursor.execute("DELETE FROM bitten_rule WHERE id=%s", (str(self.id),))
+        cursor.execute("DELETE FROM bitten_platform WHERE id=%s", (str(self.id),))
         if handle_ta:
             db.commit()
 
@@ -263,7 +263,7 @@
         cursor = db.cursor()
         cursor.execute("UPDATE bitten_platform SET name=%s WHERE id=%s",
                        (self.name, self.id))
-        cursor.execute("DELETE FROM bitten_rule WHERE id=%s", (self.id,))
+        cursor.execute("DELETE FROM bitten_rule WHERE id=%s", (str(self.id),))
         if self.rules:
             cursor.executemany("INSERT INTO bitten_rule VALUES (%s,%s,%s,%s)",
                                [(self.id, propname, pattern, idx)
@@ -280,7 +280,7 @@
 
         cursor = db.cursor()
         cursor.execute("SELECT config,name FROM bitten_platform "
-                       "WHERE id=%s", (id,))
+                       "WHERE id=%s", (str(id),))
         row = cursor.fetchone()
         if not row:
             return None
@@ -288,7 +288,7 @@
         platform = TargetPlatform(env, config=row[0], name=row[1])
         platform.id = id
         cursor.execute("SELECT propname,pattern FROM bitten_rule "
-                       "WHERE id=%s ORDER BY orderno", (id,))
+                       "WHERE id=%s", (str(id),))
         for propname, pattern in cursor:
             platform.rules.append((propname, pattern))
         return platform
@@ -494,7 +494,7 @@
         if config is not None:
             where_clauses.append(("config=%s", config))
         if rev is not None:
-            where_clauses.append(("rev=%s", rev))
+            where_clauses.append(("rev=%s", (str(rev),)))
         if platform is not None:
             where_clauses.append(("platform=%s", platform))
         if slave is not None:
