Module reahl.sqlalchemysupport¶
Various bits of support for SQLAlchemy (and declarative/Elixir).
- reahl.sqlalchemysupport.Session = <sqlalchemy.orm.scoping.ScopedSession object at 0x4b4ec90>¶
A shared SQLAlchemy session, scoped using the current reahl.component.context.ExecutionContext
- class reahl.sqlalchemysupport.Base(**kwargs)¶
A Base for using with declarative
- reahl.sqlalchemysupport.metadata = MetaData(bind=None)¶
a metadata for use with Elixir, shared with declarative classes using Base
SqlAlchemyControl¶
- class reahl.sqlalchemysupport.SqlAlchemyControl(echo=False)¶
An ORMControl for dealing with SQLAlchemy.
- nested_transaction(*args, **kwds)¶
A context manager for code that needs to run in a nested transaction.
- connect()¶
Creates the SQLAlchemy Engine, bind it to the metadata and instrument the persisted classes for the current reahlsystem.root_egg.
- disconnect()¶
Disposes the current SQLAlchemy Engine and .remove() the Session.
- commit()¶
Commits the current transaction. Programmers should not need to deal with such transaction management explicitly, since the framework already manages transactions itself.
- rollback()¶
Rolls back the current transaction. Programmers should not need to deal with such transaction management explicitly, since the framework already manages transactions itself.
QueryAsSequence¶
- class reahl.sqlalchemysupport.QueryAsSequence(query)¶
Used to wrap a SqlAlchemy Query so that it looks like a normal Python Sequence.
PersistedField¶
- class reahl.sqlalchemysupport.PersistedField(class_to_query, default=None, required=False, required_message=None, label=None, readable=None, writable=None)¶
A reahl.component.modelinterface.Field which takes an integer as input, and yields an instance of class_to_query as parsed Python object. The Python object returned is selected from the Session. The instance with ‘id’ equal to the given integer is the one returned.
Parameters: class_to_query – The class to query by id from the Session. (See reahl.component.modelinterface.Field for other arguments.)