diff --git a/CHANGELOG.md b/CHANGELOG.md index af2a2a8..fd9b296 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ *The changelog has only been started with version 0.3.12, previous changes must be reconstructed from revision history.* +* 0.5.4: Context manager for transactions, thanks to @victorkashirin. * 0.5.1: Fix a regression where empty queries would raise an exception. * 0.5: Improve overall code quality and testing, including Travis CI. An advanced __getitem__ syntax which allowed for the specification diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 8be5013..f4682ad 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -67,15 +67,17 @@ particular value, just use the auto-generated ``id`` column. Using Transactions ------------------ -You can group a set of database updates within a transaction, thus all updates are -committed at once or, in case of exception, all of them are reverted. Transactions are -supported by ``dataset`` context manager, and initiated by ``with`` statement:: +You can group a set of database updates in a transaction. In that case, all updates +are committed at once or, in case of exception, all of them are reverted. Transactions +are supported through a context manager, so they can be used through a ``with`` +statement:: with dataset.connect() as tx: tx['user'].insert(dict(name='John Doe', age=46, country='China')) -You can get same functionality with datase methods :py:meth:`all() `, -:py:meth:`all() ` and :py:meth:`rollback() `:: +You can get same functionality by invocing the methods :py:meth:`begin() `, +:py:meth:`commit() ` and :py:meth:`rollback() ` +explicitly:: db = dataset.connect() db.begin() @@ -86,6 +88,7 @@ You can get same functionality with datase methods :py:meth:`all()