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/derived_attributes/attributes.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/derived_attributes/attributes.py')
-rw-r--r-- | examples/derived_attributes/attributes.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/derived_attributes/attributes.py b/examples/derived_attributes/attributes.py index f53badc74..4a1618985 100644 --- a/examples/derived_attributes/attributes.py +++ b/examples/derived_attributes/attributes.py @@ -36,8 +36,8 @@ def hybrid_property(fget, fset=None, fdel=None): ### Example code -from sqlalchemy import * -from sqlalchemy.orm import * +from sqlalchemy import MetaData, Table, Column, Integer +from sqlalchemy.orm import mapper, create_session metadata = MetaData('sqlite://') metadata.bind.echo = True @@ -99,14 +99,14 @@ session = create_session() intervals = [Interval1(1,4), Interval1(3,15), Interval1(11,16)] for interval in intervals: - session.save(interval) - session.save(Interval2(interval.start, interval.length)) + session.add(interval) + session.add(Interval2(interval.start, interval.length)) session.flush() print "Clear the cache and do some queries" -session.clear() +session.expunge_all() for Interval in (Interval1, Interval2): print "Querying using interval class %s" % Interval.__name__ |