Author: cito
Date: Wed Jan 13 10:50:25 2016
New Revision: 734
Log:
Add documentation for transaction handling methods
Also, the savepoint name is not optional.
Modified:
branches/4.x/docs/contents/pg/db_wrapper.rst
branches/4.x/pg.py
trunk/docs/contents/pg/db_wrapper.rst
trunk/pg.py
Modified: branches/4.x/docs/contents/pg/db_wrapper.rst
==============================================================================
--- branches/4.x/docs/contents/pg/db_wrapper.rst Wed Jan 13 10:12:48
2016 (r733)
+++ branches/4.x/docs/contents/pg/db_wrapper.rst Wed Jan 13 10:50:25
2016 (r734)
@@ -126,8 +126,8 @@
Given the name of a table, digs out the set of attribute names.
-has_table_privilege -- check whether current user has specified table privilege
--------------------------------------------------------------------------------
+has_table_privilege -- check table privilege
+--------------------------------------------
.. method:: DB.has_table_privilege(table, privilege)
@@ -142,6 +142,70 @@
.. versionadded:: 4.0
+begin/commit/rollback/savepoint/release -- transaction handling
+---------------------------------------------------------------
+
+.. method:: DB.begin([mode])
+
+ Begin a transaction
+
+ :param str mode: an optional transaction mode such as 'READ ONLY'
+
+ This initiates a transaction block, that is, all following queries
+ will be executed in a single transaction until :meth:`DB.commit`
+ or :meth:`DB.rollback` is called.
+
+.. versionadded:: 4.1
+
+.. method:: DB.start()
+
+ This is the same as the :meth:`DB.begin` method.
+
+.. method:: DB.commit()
+
+ Commit a transaction
+
+ This commits the current transaction. All changes made by the
+ transaction become visible to others and are guaranteed to be
+ durable if a crash occurs.
+
+.. method:: DB.end()
+
+ This is the same as the :meth:`DB.commit` method.
+
+.. versionadded:: 4.1
+
+.. method:: DB.rollback([name])
+
+ Roll back a transaction
+
+ :param str name: optionally, roll back to the specified savepoint
+
+ This rolls back the current transaction and causes all the updates
+ made by the transaction to be discarded.
+
+.. versionadded:: 4.1
+
+.. method:: DB.savepoint(name)
+
+ Define a new savepoint
+
+ :param str name: the name to give to the new savepoint
+
+ This establishes a new savepoint within the current transaction.
+
+.. versionadded:: 4.1
+
+.. method:: DB.release(name)
+
+ Destroy a savepoint
+
+ :param str name: the name of the savepoint to destroy
+
+ This destroys a savepoint previously defined in the current transaction.
+
+.. versionadded:: 4.1
+
get -- get a row from a database table or view
----------------------------------------------
Modified: branches/4.x/pg.py
==============================================================================
--- branches/4.x/pg.py Wed Jan 13 10:12:48 2016 (r733)
+++ branches/4.x/pg.py Wed Jan 13 10:50:25 2016 (r734)
@@ -503,18 +503,15 @@
end = commit
def rollback(self, name=None):
- """Rollback the current transaction."""
+ """Roll back the current transaction."""
qstr = 'ROLLBACK'
if name:
qstr += ' TO ' + name
return self.query(qstr)
- def savepoint(self, name=None):
+ def savepoint(self, name):
"""Define a new savepoint within the current transaction."""
- qstr = 'SAVEPOINT'
- if name:
- qstr += ' ' + name
- return self.query(qstr)
+ return self.query('SAVEPOINT ' + name)
def release(self, name):
"""Destroy a previously defined savepoint."""
Modified: trunk/docs/contents/pg/db_wrapper.rst
==============================================================================
--- trunk/docs/contents/pg/db_wrapper.rst Wed Jan 13 10:12:48 2016
(r733)
+++ trunk/docs/contents/pg/db_wrapper.rst Wed Jan 13 10:50:25 2016
(r734)
@@ -125,8 +125,8 @@
Given the name of a table, digs out the set of attribute names.
-has_table_privilege -- check whether current user has specified table privilege
--------------------------------------------------------------------------------
+has_table_privilege -- check table privilege
+--------------------------------------------
.. method:: DB.has_table_privilege(table, privilege)
@@ -141,6 +141,70 @@
.. versionadded:: 4.0
+begin/commit/rollback/savepoint/release -- transaction handling
+---------------------------------------------------------------
+
+.. method:: DB.begin([mode])
+
+ Begin a transaction
+
+ :param str mode: an optional transaction mode such as 'READ ONLY'
+
+ This initiates a transaction block, that is, all following queries
+ will be executed in a single transaction until :meth:`DB.commit`
+ or :meth:`DB.rollback` is called.
+
+.. versionadded:: 4.1
+
+.. method:: DB.start()
+
+ This is the same as the :meth:`DB.begin` method.
+
+.. method:: DB.commit()
+
+ Commit a transaction
+
+ This commits the current transaction. All changes made by the
+ transaction become visible to others and are guaranteed to be
+ durable if a crash occurs.
+
+.. method:: DB.end()
+
+ This is the same as the :meth:`DB.commit` method.
+
+.. versionadded:: 4.1
+
+.. method:: DB.rollback([name])
+
+ Roll back a transaction
+
+ :param str name: optionally, roll back to the specified savepoint
+
+ This rolls back the current transaction and causes all the updates
+ made by the transaction to be discarded.
+
+.. versionadded:: 4.1
+
+.. method:: DB.savepoint(name)
+
+ Define a new savepoint
+
+ :param str name: the name to give to the new savepoint
+
+ This establishes a new savepoint within the current transaction.
+
+.. versionadded:: 4.1
+
+.. method:: DB.release(name)
+
+ Destroy a savepoint
+
+ :param str name: the name of the savepoint to destroy
+
+ This destroys a savepoint previously defined in the current transaction.
+
+.. versionadded:: 4.1
+
get -- get a row from a database table or view
----------------------------------------------
Modified: trunk/pg.py
==============================================================================
--- trunk/pg.py Wed Jan 13 10:12:48 2016 (r733)
+++ trunk/pg.py Wed Jan 13 10:50:25 2016 (r734)
@@ -445,18 +445,15 @@
end = commit
def rollback(self, name=None):
- """Rollback the current transaction."""
+ """Roll back the current transaction."""
qstr = 'ROLLBACK'
if name:
qstr += ' TO ' + name
return self.query(qstr)
- def savepoint(self, name=None):
+ def savepoint(self, name):
"""Define a new savepoint within the current transaction."""
- qstr = 'SAVEPOINT'
- if name:
- qstr += ' ' + name
- return self.query(qstr)
+ return self.query('SAVEPOINT ' + name)
def release(self, name):
"""Destroy a previously defined savepoint."""
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql