diff options
| author | Michael Trier <mtrier@gmail.com> | 2009-03-31 22:31:08 +0000 |
|---|---|---|
| committer | Michael Trier <mtrier@gmail.com> | 2009-03-31 22:31:08 +0000 |
| commit | 6010afb28f95c7050ca48ddd2e6f65ca6cbae5a1 (patch) | |
| tree | 46259c03c209a89702c32c939c8ea035edee9425 /examples/vertical/dictlike.py | |
| parent | 832ea82fefa366f4717e889511f66ecfce3313de (diff) | |
| download | sqlalchemy-6010afb28f95c7050ca48ddd2e6f65ca6cbae5a1.tar.gz | |
Lots of fixes to the code examples to specify imports explicitly.
Explicit imports make it easier for users to understand the examples.
Additionally a lot of the examples were fixed to work with the changes in the
0.5.x code base. One small correction to the Case expression. Thanks a bunch
to Adam Lowry! Fixes #717.
Diffstat (limited to 'examples/vertical/dictlike.py')
| -rw-r--r-- | examples/vertical/dictlike.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/vertical/dictlike.py b/examples/vertical/dictlike.py index 5f478d7d0..1e1635ed7 100644 --- a/examples/vertical/dictlike.py +++ b/examples/vertical/dictlike.py @@ -122,7 +122,8 @@ class VerticalPropertyDictMixin(object): if __name__ == '__main__': - from sqlalchemy import * + from sqlalchemy import (MetaData, Table, Column, Integer, Unicode, + ForeignKey, UnicodeText, and_, not_) from sqlalchemy.orm import mapper, relation, create_session from sqlalchemy.orm.collections import attribute_mapped_collection @@ -183,9 +184,9 @@ if __name__ == '__main__': # stoat.facts collection: print stoat.facts[u'color'] - session.save(stoat) + session.add(stoat) session.flush() - session.clear() + session.expunge_all() critter = session.query(Animal).filter(Animal.name == u'stoat').one() print critter[u'color'] @@ -201,17 +202,17 @@ if __name__ == '__main__': marten = Animal(u'marten') marten[u'color'] = u'brown' marten[u'cuteness'] = u'somewhat' - session.save(marten) + session.add(marten) shrew = Animal(u'shrew') shrew[u'cuteness'] = u'somewhat' shrew[u'poisonous-part'] = u'saliva' - session.save(shrew) + session.add(shrew) loris = Animal(u'slow loris') loris[u'cuteness'] = u'fairly' loris[u'poisonous-part'] = u'elbows' - session.save(loris) + session.add(loris) session.flush() q = (session.query(Animal). |
