def query(self): """ Create a session query over this model. :: Model.query.all() Equivalent to :: from alchemist.db import session session.query(Model).all() """ return session.query(self)
def test_save(self): from a.models import AWall # Create 2 models. AWall().save() AWall().save(commit=False) # Commit. from alchemist.db import session session.commit() # Query. assert len(session.query(AWall).all()) == 2 # Fetch and save. m = session.query(AWall).first() m.id = 43526 m.save() # Query. assert session.query(AWall).filter_by(id=43526).first() is not None