Changeset 734 for branches/4.x


Ignore:
Timestamp:
Jan 13, 2016, 10:50:25 AM (4 years ago)
Author:
cito
Message:

Add documentation for transaction handling methods

Also, the savepoint name is not optional.

Location:
branches/4.x
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/docs/contents/pg/db_wrapper.rst

    r728 r734  
    127127Given the name of a table, digs out the set of attribute names.
    128128
    129 has_table_privilege -- check whether current user has specified table privilege
    130 -------------------------------------------------------------------------------
     129has_table_privilege -- check table privilege
     130--------------------------------------------
    131131
    132132.. method:: DB.has_table_privilege(table, privilege)
     
    142142
    143143.. versionadded:: 4.0
     144
     145begin/commit/rollback/savepoint/release -- transaction handling
     146---------------------------------------------------------------
     147
     148.. method:: DB.begin([mode])
     149
     150    Begin a transaction
     151
     152    :param str mode: an optional transaction mode such as 'READ ONLY'
     153
     154    This initiates a transaction block, that is, all following queries
     155    will be executed in a single transaction until :meth:`DB.commit`
     156    or :meth:`DB.rollback` is called.
     157
     158.. versionadded:: 4.1
     159
     160.. method:: DB.start()
     161
     162    This is the same as the :meth:`DB.begin` method.
     163
     164.. method:: DB.commit()
     165
     166    Commit a transaction
     167
     168    This commits the current transaction. All changes made by the
     169    transaction become visible to others and are guaranteed to be
     170    durable if a crash occurs.
     171
     172.. method:: DB.end()
     173
     174    This is the same as the :meth:`DB.commit` method.
     175
     176.. versionadded:: 4.1
     177
     178.. method:: DB.rollback([name])
     179
     180    Roll back a transaction
     181
     182    :param str name: optionally, roll back to the specified savepoint
     183
     184    This rolls back the current transaction and causes all the updates
     185    made by the transaction to be discarded.
     186
     187.. versionadded:: 4.1
     188
     189.. method:: DB.savepoint(name)
     190
     191    Define a new savepoint
     192
     193    :param str name: the name to give to the new savepoint
     194
     195    This establishes a new savepoint within the current transaction.
     196
     197.. versionadded:: 4.1
     198
     199.. method:: DB.release(name)
     200
     201    Destroy a savepoint
     202
     203    :param str name: the name of the savepoint to destroy
     204
     205    This destroys a savepoint previously defined in the current transaction.
     206
     207.. versionadded:: 4.1
    144208
    145209get -- get a row from a database table or view
  • branches/4.x/pg.py

    r728 r734  
    504504
    505505    def rollback(self, name=None):
    506         """Rollback the current transaction."""
     506        """Roll back the current transaction."""
    507507        qstr = 'ROLLBACK'
    508508        if name:
     
    510510        return self.query(qstr)
    511511
    512     def savepoint(self, name=None):
     512    def savepoint(self, name):
    513513        """Define a new savepoint within the current transaction."""
    514         qstr = 'SAVEPOINT'
    515         if name:
    516             qstr += ' ' + name
    517         return self.query(qstr)
     514        return self.query('SAVEPOINT ' + name)
    518515
    519516    def release(self, name):
Note: See TracChangeset for help on using the changeset viewer.