Alchemytools

A set of helpers to be used in any SQLAlchemy project
Download

Alchemytools Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Dalton Barreto
  • Publisher web site:
  • http://github.com/daltonmatos/

Alchemytools Tags


Alchemytools Description

Alchemytools brings a set of useful tools to be used in any SQLAchemly project.The idea is to save common problems, for example: Opening/Closing sessions, commiting the sesssin only at the end of the transaction, etc.Available ToolsHere are all tools available in alchemytools.Context ManagersmanagedThis is the basic context manager and it will commit and close your session automatically, at the end of the with block. with managed(MySessionClass) as session: # Do what you need with your session # Here the session is already closed and commitedIf you raise any exception inside the with block, the session will be rolled back and the exception re-raised.Additional options- auto_flush: Sets the autoflush option on the SQLAlchemy session, defaults fo Falsecommit_on_successThis contextmanager should be used in an inner with block, where you already have an open session but need to commit more than one time. The code will be something on these lines. with managed(MySession) as session: for a in iterable: with commit_on_success(session): process(a) session.add(a)If you raise an exception inside the second with block, all previous iterations will already be commited and just the current one will be rolledback.Product's homepage


Alchemytools Related Software