rabin 7 年之前
父节点
当前提交
f3989e9924
共有 1 个文件被更改,包括 11 次插入7 次删除
  1. 11 7
      demeter/model.py

+ 11 - 7
demeter/model.py

@@ -72,13 +72,17 @@ class Model(object):
 				method = 'insert'
 		self.sql = sql
 		self.bind = bind
-		cur.execute(sql, bind)
-		if method == 'select':
-			return self.fetch(cur, fetch)
-		id = True
-		if method == 'insert':
-			id = self.lastId(cur)
-		self.commit()
+		self.addLog((sql, bind))
+		try:
+			cur.execute(sql, bind)
+			if method == 'select':
+				return self.fetch(cur, fetch)
+			id = True
+			if method == 'insert':
+				id = self.lastId(cur)
+			self.commit()
+		except Exception as e:
+			return False
 		self._set = {}
 		return id