]> git.jsancho.org Git - mojodb.git/blobdiff - MySQL.py
Savepoints to protect integrity of documents
[mojodb.git] / MySQL.py
index 98365b4d50d22629584ae39db071cd33cf8e7ae2..03969f78c5add49964e417498a6d56bc11dcb637 100644 (file)
--- a/MySQL.py
+++ b/MySQL.py
@@ -84,7 +84,7 @@ class Connection(connection.Connection):
     Constraint = Constraint
     Literal = Literal
 
-    def __init__(self, host="localhost", user=None, passwd=None, *args, **kwargs):
+    def __init__(self, host="localhost", user="", passwd="", *args, **kwargs):
         self._db_con = MySQLdb.connect(host=host, user=user, passwd=passwd)
         self._db_con_autocommit = MySQLdb.connect(host=host, user=user, passwd=passwd)
         super(Connection, self).__init__(*args, **kwargs)
@@ -171,3 +171,15 @@ class Connection(connection.Connection):
 
     def rollback(self):
         self._db_con.rollback()
+
+    def savepoint(self, name):
+        self.execute("SAVEPOINT %s" % name)
+        return True
+
+    def commit_savepoint(self, name):
+        self.execute("RELEASE SAVEPOINT %s" % name)
+        return True
+
+    def rollback_savepoint(self, name):
+        self.execute("ROLLBACK TO %s" % name)
+        return True