X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=MySQL.py;h=03969f78c5add49964e417498a6d56bc11dcb637;hb=03608c5c39b1b837fc4cf6248311b8ddad1dda2e;hp=e983a670fa957f2d082f21b6c41a729512a05716;hpb=aa509ddc8574e0a5220c94a2b72f4d5a798d6e8a;p=mojodb.git diff --git a/MySQL.py b/MySQL.py index e983a67..03969f7 100644 --- a/MySQL.py +++ b/MySQL.py @@ -84,9 +84,10 @@ class Connection(connection.Connection): Constraint = Constraint Literal = Literal - def __init__(self, *args, **kwargs): - self._db_con = MySQLdb.connect(*args, **kwargs) - self._db_con_autocommit = MySQLdb.connect(*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) def query(self, sql, db=None): if db is None: @@ -170,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