~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/db.py

  • Committer: mattgiuca
  • Date: 2008-02-18 05:42:17 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:492
db.py: Added start_transaction, commit and rollback methods (tested).

Show diffs side-by-side

added added

removed removed

Lines of Context:
260
260
        if dry: return query
261
261
        return self.db.query(query).dictresult()
262
262
 
 
263
    def start_transaction(self, dry=False):
 
264
        """Starts a DB transaction.
 
265
        Will not commit any changes until self.commit() is called.
 
266
        """
 
267
        query = "START TRANSACTION;"
 
268
        if dry: return query
 
269
        self.db.query(query)
 
270
 
 
271
    def commit(self, dry=False):
 
272
        """Commits (ends) a DB transaction.
 
273
        Commits all changes since the call to start_transaction.
 
274
        """
 
275
        query = "COMMIT;"
 
276
        if dry: return query
 
277
        self.db.query(query)
 
278
 
 
279
    def rollback(self, dry=False):
 
280
        """Rolls back (ends) a DB transaction, undoing all changes since the
 
281
        call to start_transaction.
 
282
        """
 
283
        query = "ROLLBACK;"
 
284
        if dry: return query
 
285
        self.db.query(query)
 
286
 
263
287
    # USER MANAGEMENT FUNCTIONS #
264
288
 
265
289
    login_primary = frozenset(["login"])