diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-27 17:21:31 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-27 17:21:31 -0400 |
| commit | 8cdb4543bd7a85bef0286433576aafe0fb8e7c4c (patch) | |
| tree | 4f69b10e11a0cb6e58f0bab326a534b7dbcd12f8 /examples/vertical | |
| parent | 5f51d409ccda1033a41256dfc28e46bc6923521d (diff) | |
| download | sqlalchemy-8cdb4543bd7a85bef0286433576aafe0fb8e7c4c.tar.gz | |
modernize some more examples
Diffstat (limited to 'examples/vertical')
| -rw-r--r-- | examples/vertical/dictlike-polymorphic.py | 3 | ||||
| -rw-r--r-- | examples/vertical/dictlike.py | 14 |
2 files changed, 6 insertions, 11 deletions
diff --git a/examples/vertical/dictlike-polymorphic.py b/examples/vertical/dictlike-polymorphic.py index c4eb6b5ce..f800eea73 100644 --- a/examples/vertical/dictlike-polymorphic.py +++ b/examples/vertical/dictlike-polymorphic.py @@ -254,6 +254,3 @@ if __name__ == '__main__': q = (session.query(AnimalFact). filter(with_characteristic(u'cuteness', u'very cute'))) print q.all() - - session.close() - metadata.drop_all(engine) diff --git a/examples/vertical/dictlike.py b/examples/vertical/dictlike.py index e288d70ba..71ab77342 100644 --- a/examples/vertical/dictlike.py +++ b/examples/vertical/dictlike.py @@ -124,7 +124,7 @@ class VerticalPropertyDictMixin(object): if __name__ == '__main__': from sqlalchemy import (MetaData, Table, Column, Integer, Unicode, - ForeignKey, UnicodeText, and_, not_) + ForeignKey, UnicodeText, and_, not_, create_engine) from sqlalchemy.orm import mapper, relationship, Session from sqlalchemy.orm.collections import attribute_mapped_collection @@ -172,10 +172,9 @@ if __name__ == '__main__': }) mapper(AnimalFact, facts) - - metadata.bind = 'sqlite:///' - metadata.create_all() - session = Session() + engine = create_engine("sqlite://") + metadata.create_all(engine) + session = Session(bind=engine) stoat = Animal(u'stoat') stoat[u'color'] = u'reddish' @@ -195,9 +194,9 @@ if __name__ == '__main__': critter[u'cuteness'] = u'very' print 'changing cuteness:' - metadata.bind.echo = True + engine.echo = True session.commit() - metadata.bind.echo = False + engine.echo = False marten = Animal(u'marten') marten[u'color'] = u'brown' @@ -245,4 +244,3 @@ if __name__ == '__main__': print 'just the facts', q.all() - metadata.drop_all() |
